SHBlendModes

type:
extension
author:
Shilo White
description:
A category that allows blend modes via presets or custom blends.
lastupdate:
2012-03-11
compatible:
v1.X
tag:
blend, blending, mode, blend mode
homepage:
https://gist.github.com/2019733
download:
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 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 blendModeSourceFactor and 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

  users/shilo/extensions/shblendmodes.txt · Last modified: 2013/03/05 10:19 (external edit)
 
Powered by DokuWiki