blendmode

    Dark Mode
Search:
Group by:

blendmode.nim

Header file declaring the BlendMode enumeration.

Types

BlendMode* {...}{.size: sizeof(cint).} = enum
  BLENDMODE_NONE = 0x00000000, ## no blending
                                ## dstRGBA = srcRGBA
  BLENDMODE_BLEND = 0x00000001, ## alpha blending
                                 ## dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
                                 ## dstA = srcA + (dstA * (1-srcA))
  BLENDMODE_ADD = 0x00000002, ## additive blending
                               ## dstRGB = (srcRGB * srcA) + dstRGB
                               ## dstA = dstA
  BLENDMODE_MOD = 0x00000004, ## color modulate
                               ## dstRGB = srcRGB * dstRGB
                               ## dstA = dstA
  BLENDMODE_MUL = 0x00000008, ## color multiply
                               ## dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
                               ## dstA = (srcA * dstA) + (dstA * (1-srcA))
  BLENDMODE_INVALID = 0x7FFFFFFF

The blend mode used in renderCopy() and drawing operations.

Additional custom blend modes can be returned by composeCustomBlendMode().

BlendOperation* {...}{.size: sizeof(cint).} = enum
  BLENDOPERATION_ADD = 0x00000001, ## dst + src : supported by all renderers
  BLENDOPERATION_SUBTRACT = 0x00000002, ## dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES
  BLENDOPERATION_REV_SUBTRACT = 0x00000003, ## src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES
  BLENDOPERATION_MINIMUM = 0x00000004, ## min(dst, src) : supported by D3D11
  BLENDOPERATION_MAXIMUM = 0x00000005 ## max(dst, src) : supported by D3D11
The blend operation used when combining source and destination pixel components.
BlendFactor* {...}{.size: sizeof(cint).} = enum
  BLENDFACTOR_ZERO = 0x00000001, ## 0, 0, 0, 0
  BLENDFACTOR_ONE = 0x00000002, ## 1, 1, 1, 1
  BLENDFACTOR_SRC_COLOR = 0x00000003, ## srcR, srcG, srcB, srcA
  BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x00000004, ## 1-srcR, 1-srcG, 1-srcB, 1-srcA
  BLENDFACTOR_SRC_ALPHA = 0x00000005, ## srcA, srcA, srcA, srcA
  BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x00000006, ## 1-srcA, 1-srcA, 1-srcA, 1-srcA
  BLENDFACTOR_DST_COLOR = 0x00000007, ## dstR, dstG, dstB, dstA
  BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x00000008, ## 1-dstR, 1-dstG, 1-dstB, 1-dstA
  BLENDFACTOR_DST_ALPHA = 0x00000009, ## dstA, dstA, dstA, dstA
  BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0x0000000A ## 1-dstA, 1-dstA, 1-dstA, 1-dstA
The normalized factor used to multiply pixel components.

Procs

proc composeCustomBlendMode*(srcColorFactor: BlendFactor;
                             dstColorFactor: BlendFactor;
                             colorOperation: BlendOperation;
                             srcAlphaFactor: BlendFactor;
                             dstAlphaFactor: BlendFactor;
                             alphaOperation: BlendOperation): BlendMode {...}{.cdecl,
    importc: "SDL_ComposeCustomBlendMode", dynlib: SDL2_LIB.}

Create a custom blend mode, which may or may not be supported by a given renderer.

srcColorFactor source color factor

dstColorFactor destination color factor

colorOperation color operation

srcAlphaFactor source alpha factor

dstAlphaFactor destination alpha factor

alphaOperation alpha operation

The result of the blend mode operation will be:

dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor

and

dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor