Filters

Set of image filters

Shadow & Gradient

pgext.filters.shadow(surface, tuple color [, int radius=5 [, bool resized=False [, float opacity=1.0]]])

Create RGBA surface shadow with given radius and opacity. If resized is True than output surface will be resized to ( width+radius*2, height+radius*2 ).
Original surface is not modified.

Example
image = pgext.filters.shadow( image, (0,0,0), 5, 1, 0.9 )
image = pgext.filters.shadow( image, (255,0,0), 10, 0, 0.9 )
   

pgext.filters.gradient(tuple size, tuple start_color, tuple end_color [, bool vertical=0 [, float ratio=1.0 ]])

Create vertical/horizontal gradient of given size. start_color and end_color should be instance of pygame.Color or tuple of 3 or 4 Uint8s.
Examples
# example 1
image = pgext.filters.gradient((200, 200), (100, 100, 200), (100, 200, 100), 0, 1.0)

# example 2 - gradient with ratio & alpha
image = pgext.filters.gradient((200, 200 ), (255, 0, 0, 0), (0, 0, 255, 255), 0, 0.3)

# example 3 - vertical gradient
image = pgext.filters.gradient((200,200), (100, 0, 0), (0,55,55), 1, 1.0)
   

Blur effects

pgext.filters.blur(surface [, int radius=4 ])

Apply simple blur on surface.
Original surface is modified.

Example
pgext.filters.blur( image, 4 )
  

pgext.filters.hvBlur(surface [, int radius=4 [, bool vertical=0 ]])

Horizontal/vertical blur.
Original surface is modified.

Examples
# horizontal
pgext.filters.hvBlur( image, 4 )

# vertical
pgext.filters.hvBlur( image, 4, True )
   

Other effects

pgext.filters.noise(surface [, int value=255 [, int density=5]])

Apply simple noise on surface. value is +/- shift of RGB values and density is number of skipped pixels (smaller number == more changed pixel == slower ).
Original surface is modified.

Example
pgext.filters.noise(image, 55, 2)
  

pgext.filters.noiseBlur(surface [, int radius=5 [, bool blend=False]])

Fast and ugly "blur" effect :)
Original surface is modified.

Example
# Faster (no blending)
pgext.filters.noiseBlur(image, 5)

# With blending
pgext.filters.noiseBlur(image, 20, 1)
   

pgext.filters.scratch(surface [, int offset=10])

Apply vertical "scratch" effect on surface.
Original surface is modified.

Example
pgext.filters.scratch(image, 5)
  

pgext.filters.pixelize(surface [, int size=10])

Fast function for simple pixelize effect.
Original surface is modified.
New in version 1.12.

Example
pgext.filters.pixelize(image, 10)
  

pgext.filters.ripple(surface, int frequency, int amplitude [, float phase=0.0 [, bool vertical=False]])

Fast ripple effect. You can make water effect easily with this.
Original surface is modified.
New in version 1.16.

Example
pgext.filters.ripple(image, 30, 4)