Generated by Cython 0.29.21

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

Raw output: misc.c

+001: # cython: binding=False, boundscheck=False, wraparound=False, nonecheck=False, cdivision=True,
  __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_5) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 002: # cython: optimize.use_switch=True
 003: # encoding: utf-8
 004: 
 005: """
 006:                  GNU GENERAL PUBLIC LICENSE
 007:                        Version 3, 29 June 2007
 008: 
 009:  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 010:  Everyone is permitted to copy and distribute verbatim copies
 011:  of this license document, but changing it is not allowed.
 012: 
 013: Copyright Yoann Berenguer
 014: """
 015: 
+016: try:
  {
    /*try:*/ {
/* … */
    }
  }
 017:     cimport cython
 018:     from cython.parallel cimport prange
 019: 
 020: except ImportError:
 021:     raise ImportError("\n<cython> library is missing on your system."
 022:           "\nTry: \n   C:\\pip install cython on a window command prompt.")
 023: 
 024: 
+025: try:
  {
    /*try:*/ {
/* … */
    }
  }
 026:     cimport cython
 027:     from cython.parallel cimport prange
 028:     from cpython cimport PyObject_CallFunctionObjArgs, PyObject, \
 029:         PyList_SetSlice, PyObject_HasAttr, PyObject_IsInstance, \
 030:         PyObject_CallMethod, PyObject_CallObject
 031: 
 032: 
 033: except ImportError:
 034:     raise ImportError("\n<cython> library is missing on your system."
 035:           "\nTry: \n   C:\\pip install cython on a window command prompt.")
 036: 
 037: 
 038: 
+039: try:
  {
    /*try:*/ {
/* … */
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L19_try_end;
    __pyx_L14_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
/* … */
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L19_try_end:;
  }
+040:     import pygame
      __pyx_t_4 = __Pyx_Import(__pyx_n_s_pygame, 0, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 40, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_pygame, __pyx_t_4) < 0) __PYX_ERR(0, 40, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+041:     from pygame import Rect
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_s_Rect);
      __Pyx_GIVEREF(__pyx_n_s_Rect);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_Rect);
      __pyx_t_5 = __Pyx_Import(__pyx_n_s_pygame, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 41, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_Rect); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 41, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_Rect, __pyx_t_4) < 0) __PYX_ERR(0, 41, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+042:     from pygame.math import Vector2
      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 42, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_n_s_Vector2);
      __Pyx_GIVEREF(__pyx_n_s_Vector2);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_Vector2);
      __pyx_t_4 = __Pyx_Import(__pyx_n_s_pygame_math, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Vector2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 42, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_Vector2, __pyx_t_5) < 0) __PYX_ERR(0, 42, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+043:     from pygame import Rect, BLEND_RGB_ADD, HWACCEL
      __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_s_Rect);
      __Pyx_GIVEREF(__pyx_n_s_Rect);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_Rect);
      __Pyx_INCREF(__pyx_n_s_BLEND_RGB_ADD);
      __Pyx_GIVEREF(__pyx_n_s_BLEND_RGB_ADD);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_BLEND_RGB_ADD);
      __Pyx_INCREF(__pyx_n_s_HWACCEL);
      __Pyx_GIVEREF(__pyx_n_s_HWACCEL);
      PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_HWACCEL);
      __pyx_t_5 = __Pyx_Import(__pyx_n_s_pygame, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_Rect); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_Rect, __pyx_t_4) < 0) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_BLEND_RGB_ADD, __pyx_t_4) < 0) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_HWACCEL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_HWACCEL, __pyx_t_4) < 0) __PYX_ERR(0, 43, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+044:     from pygame import Surface, SRCALPHA, mask, RLEACCEL
      __pyx_t_5 = PyList_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_n_s_Surface);
      __Pyx_GIVEREF(__pyx_n_s_Surface);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_Surface);
      __Pyx_INCREF(__pyx_n_s_SRCALPHA);
      __Pyx_GIVEREF(__pyx_n_s_SRCALPHA);
      PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_SRCALPHA);
      __Pyx_INCREF(__pyx_n_s_mask);
      __Pyx_GIVEREF(__pyx_n_s_mask);
      PyList_SET_ITEM(__pyx_t_5, 2, __pyx_n_s_mask);
      __Pyx_INCREF(__pyx_n_s_RLEACCEL);
      __Pyx_GIVEREF(__pyx_n_s_RLEACCEL);
      PyList_SET_ITEM(__pyx_t_5, 3, __pyx_n_s_RLEACCEL);
      __pyx_t_4 = __Pyx_Import(__pyx_n_s_pygame, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Surface); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_Surface, __pyx_t_5) < 0) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_SRCALPHA); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_SRCALPHA, __pyx_t_5) < 0) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_mask); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_mask, __pyx_t_5) < 0) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_RLEACCEL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_RLEACCEL, __pyx_t_5) < 0) __PYX_ERR(0, 44, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+045:     from pygame.transform import rotate, scale, smoothscale
      __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_s_rotate);
      __Pyx_GIVEREF(__pyx_n_s_rotate);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_rotate);
      __Pyx_INCREF(__pyx_n_s_scale);
      __Pyx_GIVEREF(__pyx_n_s_scale);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_s_scale);
      __Pyx_INCREF(__pyx_n_s_smoothscale);
      __Pyx_GIVEREF(__pyx_n_s_smoothscale);
      PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_s_smoothscale);
      __pyx_t_5 = __Pyx_Import(__pyx_n_s_pygame_transform, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_rotate); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_rotate, __pyx_t_4) < 0) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_scale); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_scale, __pyx_t_4) < 0) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_smoothscale, __pyx_t_4) < 0) __PYX_ERR(0, 45, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+046:     from pygame.surfarray import array3d, pixels3d, array_alpha, pixels_alpha, \
      __pyx_t_5 = PyList_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_n_s_array3d);
      __Pyx_GIVEREF(__pyx_n_s_array3d);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_array3d);
      __Pyx_INCREF(__pyx_n_s_pixels3d);
      __Pyx_GIVEREF(__pyx_n_s_pixels3d);
      PyList_SET_ITEM(__pyx_t_5, 1, __pyx_n_s_pixels3d);
      __Pyx_INCREF(__pyx_n_s_array_alpha);
      __Pyx_GIVEREF(__pyx_n_s_array_alpha);
      PyList_SET_ITEM(__pyx_t_5, 2, __pyx_n_s_array_alpha);
      __Pyx_INCREF(__pyx_n_s_pixels_alpha);
      __Pyx_GIVEREF(__pyx_n_s_pixels_alpha);
      PyList_SET_ITEM(__pyx_t_5, 3, __pyx_n_s_pixels_alpha);
      __Pyx_INCREF(__pyx_n_s_make_surface);
      __Pyx_GIVEREF(__pyx_n_s_make_surface);
      PyList_SET_ITEM(__pyx_t_5, 4, __pyx_n_s_make_surface);
      __pyx_t_4 = __Pyx_Import(__pyx_n_s_pygame_surfarray, __pyx_t_5, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_array3d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_array3d, __pyx_t_5) < 0) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels3d, __pyx_t_5) < 0) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_array_alpha); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_alpha, __pyx_t_5) < 0) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_pixels_alpha); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels_alpha, __pyx_t_5) < 0) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_surface, __pyx_t_5) < 0) __PYX_ERR(0, 47, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 047:         make_surface
+048:     from pygame.image import frombuffer
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 48, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_n_s_frombuffer);
      __Pyx_GIVEREF(__pyx_n_s_frombuffer);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_frombuffer);
      __pyx_t_5 = __Pyx_Import(__pyx_n_s_pygame_image, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 48, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 48, __pyx_L14_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_frombuffer, __pyx_t_4) < 0) __PYX_ERR(0, 48, __pyx_L14_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 049: 
+050: except ImportError:
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("PygameShader.misc", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 50, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_7);
+051:     raise ImportError("\n<Pygame> library is missing on your system."
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 51, __pyx_L16_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 51, __pyx_L16_except_error)
    }
    goto __pyx_L16_except_error;
    __pyx_L16_except_error:;
/* … */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_Pygame_library_is_missing_on_yo); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 51, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);
 052:           "\nTry: \n   C:\\pip install pygame on a window command prompt.")
 053: 
 054: 
 055: # NUMPY IS REQUIRED
+056: try:
  {
    /*try:*/ {
/* … */
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    goto __pyx_L27_try_end;
    __pyx_L22_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
/* … */
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1);
    goto __pyx_L1_error;
    __pyx_L27_try_end:;
  }
+057:     import numpy
      __pyx_t_7 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 57, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_7) < 0) __PYX_ERR(0, 57, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+058:     from numpy import ndarray, zeros, empty, uint8, int32, float64, \
      __pyx_t_7 = PyList_New(19); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_n_s_ndarray);
      __Pyx_GIVEREF(__pyx_n_s_ndarray);
      PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s_ndarray);
      __Pyx_INCREF(__pyx_n_s_zeros);
      __Pyx_GIVEREF(__pyx_n_s_zeros);
      PyList_SET_ITEM(__pyx_t_7, 1, __pyx_n_s_zeros);
      __Pyx_INCREF(__pyx_n_s_empty);
      __Pyx_GIVEREF(__pyx_n_s_empty);
      PyList_SET_ITEM(__pyx_t_7, 2, __pyx_n_s_empty);
      __Pyx_INCREF(__pyx_n_s_uint8);
      __Pyx_GIVEREF(__pyx_n_s_uint8);
      PyList_SET_ITEM(__pyx_t_7, 3, __pyx_n_s_uint8);
      __Pyx_INCREF(__pyx_n_s_int32);
      __Pyx_GIVEREF(__pyx_n_s_int32);
      PyList_SET_ITEM(__pyx_t_7, 4, __pyx_n_s_int32);
      __Pyx_INCREF(__pyx_n_s_float64);
      __Pyx_GIVEREF(__pyx_n_s_float64);
      PyList_SET_ITEM(__pyx_t_7, 5, __pyx_n_s_float64);
      __Pyx_INCREF(__pyx_n_s_float32);
      __Pyx_GIVEREF(__pyx_n_s_float32);
      PyList_SET_ITEM(__pyx_t_7, 6, __pyx_n_s_float32);
      __Pyx_INCREF(__pyx_n_s_dstack);
      __Pyx_GIVEREF(__pyx_n_s_dstack);
      PyList_SET_ITEM(__pyx_t_7, 7, __pyx_n_s_dstack);
      __Pyx_INCREF(__pyx_n_s_full);
      __Pyx_GIVEREF(__pyx_n_s_full);
      PyList_SET_ITEM(__pyx_t_7, 8, __pyx_n_s_full);
      __Pyx_INCREF(__pyx_n_s_ones);
      __Pyx_GIVEREF(__pyx_n_s_ones);
      PyList_SET_ITEM(__pyx_t_7, 9, __pyx_n_s_ones);
      __Pyx_INCREF(__pyx_n_s_asarray);
      __Pyx_GIVEREF(__pyx_n_s_asarray);
      PyList_SET_ITEM(__pyx_t_7, 10, __pyx_n_s_asarray);
      __Pyx_INCREF(__pyx_n_s_ascontiguousarray);
      __Pyx_GIVEREF(__pyx_n_s_ascontiguousarray);
      PyList_SET_ITEM(__pyx_t_7, 11, __pyx_n_s_ascontiguousarray);
      __Pyx_INCREF(__pyx_n_s_full_like);
      __Pyx_GIVEREF(__pyx_n_s_full_like);
      PyList_SET_ITEM(__pyx_t_7, 12, __pyx_n_s_full_like);
      __Pyx_INCREF(__pyx_n_s_add);
      __Pyx_GIVEREF(__pyx_n_s_add);
      PyList_SET_ITEM(__pyx_t_7, 13, __pyx_n_s_add);
      __Pyx_INCREF(__pyx_n_s_putmask);
      __Pyx_GIVEREF(__pyx_n_s_putmask);
      PyList_SET_ITEM(__pyx_t_7, 14, __pyx_n_s_putmask);
      __Pyx_INCREF(__pyx_n_s_int16);
      __Pyx_GIVEREF(__pyx_n_s_int16);
      PyList_SET_ITEM(__pyx_t_7, 15, __pyx_n_s_int16);
      __Pyx_INCREF(__pyx_n_s_arange);
      __Pyx_GIVEREF(__pyx_n_s_arange);
      PyList_SET_ITEM(__pyx_t_7, 16, __pyx_n_s_arange);
      __Pyx_INCREF(__pyx_n_s_repeat);
      __Pyx_GIVEREF(__pyx_n_s_repeat);
      PyList_SET_ITEM(__pyx_t_7, 17, __pyx_n_s_repeat);
      __Pyx_INCREF(__pyx_n_s_newaxis);
      __Pyx_GIVEREF(__pyx_n_s_newaxis);
      PyList_SET_ITEM(__pyx_t_7, 18, __pyx_n_s_newaxis);
      __pyx_t_4 = __Pyx_Import(__pyx_n_s_numpy, __pyx_t_7, -1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ndarray, __pyx_t_7) < 0) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_zeros, __pyx_t_7) < 0) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_empty, __pyx_t_7) < 0) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_uint8, __pyx_t_7) < 0) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_int32, __pyx_t_7) < 0) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_float64, __pyx_t_7) < 0) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_float32, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_dstack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_dstack, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_full); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_full, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ones, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_asarray, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ascontiguousarray, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_full_like); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_full_like, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_add); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_add, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_putmask); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_putmask, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_int16, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_arange); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_arange, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_repeat); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_repeat, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_newaxis); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L22_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_newaxis, __pyx_t_7) < 0) __PYX_ERR(0, 60, __pyx_L22_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 059:         float32, dstack, full, ones, asarray, ascontiguousarray, full_like,\
 060:         add, putmask, int16, arange, repeat, newaxis
+061: except ImportError:
    __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("PygameShader.misc", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 61, __pyx_L24_except_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_GOTREF(__pyx_t_5);
+062:     raise ImportError("\n<numpy> library is missing on your system."
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 62, __pyx_L24_except_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 62, __pyx_L24_except_error)
    }
    goto __pyx_L24_except_error;
    __pyx_L24_except_error:;
/* … */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_numpy_library_is_missing_on_you); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
 063:           "\nTry: \n   C:\\pip install numpy on a window command prompt.")
 064: 
 065: from shader cimport hsv, rgb, minf, struct_rgb_to_hsv
 066: from libc.math cimport round as round_c
 067: from libc.math cimport floor as floor_c, sqrt
 068: from libc.math cimport fabs as abs_c
 069: from libc.stdlib cimport malloc, free
 070: from libc.stdio cimport printf
 071: 
 072: 
+073: import numpy
  __pyx_t_5 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_5) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 074: cimport numpy as np
 075: 
 076: DEF SCHEDULE = 'static'
 077: 
 078: DEF OPENMP = True
 079: # num_threads – The num_threads argument indicates how many threads the team should consist of.
 080: # If not given, OpenMP will decide how many threads to use.
 081: # Typically this is the number of cores available on the machine. However,
 082: # this may be controlled through the omp_set_num_threads() function,
 083: # or through the OMP_NUM_THREADS environment variable.
 084: DEF THREAD_NUMBER = 1
 085: if OPENMP is True:
 086:     DEF THREAD_NUMBER = 8
 087: 
 088: 
 089: @cython.boundscheck(False)
 090: @cython.wraparound(False)
 091: @cython.nonecheck(False)
 092: @cython.cdivision(True)
+093: cpdef swap_channels24_c(surface_, model):
static PyObject *__pyx_pw_12PygameShader_4misc_1swap_channels24_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_12PygameShader_4misc_swap_channels24_c(PyObject *__pyx_v_surface_, PyObject *__pyx_v_model, CYTHON_UNUSED int __pyx_skip_dispatch) {
  PyObject *__pyx_v_rr = NULL;
  PyObject *__pyx_v_gg = NULL;
  PyObject *__pyx_v_bb = NULL;
  PyObject *__pyx_v_order = NULL;
  Py_ssize_t __pyx_v_width;
  Py_ssize_t __pyx_v_height;
  PyObject *__pyx_v_rgb_ = NULL;
  __Pyx_memviewslice __pyx_v_rgb_array = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_new_array = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_i;
  int __pyx_v_j;
  short __pyx_v_ri;
  short __pyx_v_gi;
  short __pyx_v_bi;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("swap_channels24_c", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __PYX_XDEC_MEMVIEW(&__pyx_t_20, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
  __Pyx_AddTraceback("PygameShader.misc.swap_channels24_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_rr);
  __Pyx_XDECREF(__pyx_v_gg);
  __Pyx_XDECREF(__pyx_v_bb);
  __Pyx_XDECREF(__pyx_v_order);
  __Pyx_XDECREF(__pyx_v_rgb_);
  __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_new_array, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_12PygameShader_4misc_1swap_channels24_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_12PygameShader_4misc_swap_channels24_c[] = "\n    THIS PLUGIN ALLOW YOU TO SWAP CHANNEL OF AN IMAGE \n    \n    :param surface_: pygame.Surface\n    :param model: python string; String representing the channel order e.g\n    RGB, RBG, GRB, GBR, BRG, BGR etc. letters can also be replaced by the digit 0\n    to null the entire channel. e.g : 'R0B' -> no green channel\n\n    ";
static PyObject *__pyx_pw_12PygameShader_4misc_1swap_channels24_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_surface_ = 0;
  PyObject *__pyx_v_model = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("swap_channels24_c (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_model,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_surface)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_model)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("swap_channels24_c", 1, 2, 2, 1); __PYX_ERR(0, 93, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "swap_channels24_c") < 0)) __PYX_ERR(0, 93, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_surface_ = values[0];
    __pyx_v_model = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("swap_channels24_c", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 93, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("PygameShader.misc.swap_channels24_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_12PygameShader_4misc_swap_channels24_c(__pyx_self, __pyx_v_surface_, __pyx_v_model);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_12PygameShader_4misc_swap_channels24_c(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, PyObject *__pyx_v_model) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("swap_channels24_c", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_12PygameShader_4misc_swap_channels24_c(__pyx_v_surface_, __pyx_v_model, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("PygameShader.misc.swap_channels24_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 094:     """
 095:     THIS PLUGIN ALLOW YOU TO SWAP CHANNEL OF AN IMAGE 
 096:     
 097:     :param surface_: pygame.Surface
 098:     :param model: python string; String representing the channel order e.g
 099:     RGB, RBG, GRB, GBR, BRG, BGR etc. letters can also be replaced by the digit 0
 100:     to null the entire channel. e.g : 'R0B' -> no green channel
 101: 
 102:     """
+103:     assert PyObject_IsInstance(surface_, Surface), \
  #ifndef CYTHON_WITHOUT_ASSERTIONS
  if (unlikely(!Py_OptimizeFlag)) {
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 103, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!(__pyx_t_2 != 0))) {
+104:            'Expecting Surface for argument surface_ got %s ' % type(surface_)
      __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Expecting_Surface_for_argument_s, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __PYX_ERR(0, 103, __pyx_L1_error)
    }
  }
  #endif
 105: 
+106:     if len(model) != 3:
  __pyx_t_3 = PyObject_Length(__pyx_v_model); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 106, __pyx_L1_error)
  __pyx_t_2 = ((__pyx_t_3 != 3) != 0);
  if (__pyx_t_2) {
/* … */
  }
+107:         print("\nArgument model is invalid.")
    if (__Pyx_PrintOne(0, __pyx_kp_s_Argument_model_is_invalid) < 0) __PYX_ERR(0, 107, __pyx_L1_error)
+108:         raise ValueError("Choose between RGB, RBG, GRB, GBR, BRG, BGR")
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __PYX_ERR(0, 108, __pyx_L1_error)
/* … */
  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Choose_between_RGB_RBG_GRB_GBR_B); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 108, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);
 109: 
+110:     rr, gg, bb = list(model)
  __pyx_t_1 = PySequence_List(__pyx_v_model); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (1) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 3)) {
      if (size > 3) __Pyx_RaiseTooManyValuesError(3);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 110, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
    __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_v_rr = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_gg = __pyx_t_5;
  __pyx_t_5 = 0;
  __pyx_v_bb = __pyx_t_6;
  __pyx_t_6 = 0;
+111:     order = {'R' : 0, 'G' : 1, 'B' : 2, '0': -1}
  __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_R, __pyx_int_0) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_G, __pyx_int_1) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_B, __pyx_int_2) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_kp_s_0, __pyx_int_neg_1) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
  __pyx_v_order = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 112: 
 113:     cdef Py_ssize_t width, height
+114:     width, height = surface_.get_size()
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 114, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_4), 2) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 114, __pyx_L1_error)
    __pyx_L5_unpacking_done:;
  }
  __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_6); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_width = __pyx_t_3;
  __pyx_v_height = __pyx_t_8;
 115: 
+116:     try:
  {
    /*try:*/ {
/* … */
    }
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L11_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
/* … */
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
    goto __pyx_L1_error;
    __pyx_L7_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
    __pyx_L11_try_end:;
  }
+117:         rgb_ = pixels3d(surface_)
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 117, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_surface_);
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_rgb_ = __pyx_t_1;
      __pyx_t_1 = 0;
+118:     except (pygame.error, ValueError):
    __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pygame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L8_except_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 118, __pyx_L8_except_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_12) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_ValueError);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_6);
    __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_6 = 0;
    if (__pyx_t_13) {
      __Pyx_AddTraceback("PygameShader.misc.swap_channels24_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 118, __pyx_L8_except_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_t_1);
+119:         try:
      {
        /*try:*/ {
/* … */
        }
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        goto __pyx_L21_try_end;
        __pyx_L14_error:;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
/* … */
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        goto __pyx_L8_except_error;
        __pyx_L21_try_end:;
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L7_exception_handled;
    }
    goto __pyx_L8_except_error;
    __pyx_L8_except_error:;
+120:             rgb_ = array3d(surface_)
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_array3d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = NULL;
          if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_4);
            if (likely(__pyx_t_17)) {
              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(function);
              __Pyx_DECREF_SET(__pyx_t_4, function);
            }
          }
          __pyx_t_12 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_17, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_surface_);
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 120, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF_SET(__pyx_v_rgb_, __pyx_t_12);
          __pyx_t_12 = 0;
+121:         except(pygame.error, ValueError):
        __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_4, &__pyx_t_17);
        __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_pygame); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 121, __pyx_L16_except_error)
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_error); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 121, __pyx_L16_except_error)
        __Pyx_GOTREF(__pyx_t_19);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_13 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_12, __pyx_t_19) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_12, __pyx_builtin_ValueError);
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_ErrRestore(__pyx_t_12, __pyx_t_4, __pyx_t_17);
        __pyx_t_12 = 0; __pyx_t_4 = 0; __pyx_t_17 = 0;
        if (__pyx_t_13) {
          __Pyx_AddTraceback("PygameShader.misc.swap_channels24_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_17, &__pyx_t_4, &__pyx_t_12) < 0) __PYX_ERR(0, 121, __pyx_L16_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GOTREF(__pyx_t_12);
+122:             raise ValueError('\nIncompatible pixel format.')
          __pyx_t_19 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 122, __pyx_L16_except_error)
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_Raise(__pyx_t_19, 0, 0, 0);
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __PYX_ERR(0, 122, __pyx_L16_except_error)
        }
        goto __pyx_L16_except_error;
        __pyx_L16_except_error:;
/* … */
  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Incompatible_pixel_format); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 122, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);
 123: 
 124:     cdef:
+125:         unsigned char [:, :, :] rgb_array = rgb_
  __pyx_t_20 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_20.memview)) __PYX_ERR(0, 125, __pyx_L1_error)
  __pyx_v_rgb_array = __pyx_t_20;
  __pyx_t_20.memview = NULL;
  __pyx_t_20.data = NULL;
+126:         unsigned char [:, :, ::1] new_array = empty((height, width, 3), dtype=uint8)
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_height); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_width); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_6);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_int_3);
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_new_array = __pyx_t_21;
  __pyx_t_21.memview = NULL;
  __pyx_t_21.data = NULL;
+127:         int i=0, j=0
  __pyx_v_i = 0;
  __pyx_v_j = 0;
 128:         short int ri, gi, bi
 129: 
+130:     ri = order[rr]
  __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_order, __pyx_v_rr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_22 = __Pyx_PyInt_As_short(__pyx_t_5); if (unlikely((__pyx_t_22 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_ri = __pyx_t_22;
+131:     gi = order[gg]
  __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_order, __pyx_v_gg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_22 = __Pyx_PyInt_As_short(__pyx_t_5); if (unlikely((__pyx_t_22 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 131, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_gi = __pyx_t_22;
+132:     bi = order[bb]
  __pyx_t_5 = __Pyx_PyDict_GetItem(__pyx_v_order, __pyx_v_bb); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_22 = __Pyx_PyInt_As_short(__pyx_t_5); if (unlikely((__pyx_t_22 == (short)-1) && PyErr_Occurred())) __PYX_ERR(0, 132, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_bi = __pyx_t_22;
 133: 
+134:     with nogil:
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {
/* … */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L26;
        }
        __pyx_L26:;
      }
  }
+135:         for i in prange(width, schedule=SCHEDULE, num_threads=THREAD_NUMBER):
        __pyx_t_8 = __pyx_v_width;
        if ((1 == 0)) abort();
        {
            #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                #undef likely
                #undef unlikely
                #define likely(x)   (x)
                #define unlikely(x) (x)
            #endif
            __pyx_t_23 = (__pyx_t_8 - 0 + 1 - 1/abs(1)) / 1;
            if (__pyx_t_23 > 0)
            {
                #ifdef _OPENMP
                #pragma omp parallel
                #endif /* _OPENMP */
                {
                    #ifdef _OPENMP
                    #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) schedule(static) num_threads(8)
                    #endif /* _OPENMP */
                    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_23; __pyx_t_3++){
                        {
                            __pyx_v_i = (int)(0 + 1 * __pyx_t_3);
                            /* Initialize private variables to invalid values */
                            __pyx_v_j = ((int)0xbad0bad0);
+136:             for j in range(height):
                            __pyx_t_24 = __pyx_v_height;
                            __pyx_t_25 = __pyx_t_24;
                            for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_25; __pyx_t_13+=1) {
                              __pyx_v_j = __pyx_t_13;
+137:                 if ri == -1:
                              __pyx_t_2 = ((__pyx_v_ri == -1L) != 0);
                              if (__pyx_t_2) {
/* … */
                                goto __pyx_L33;
                              }
+138:                     new_array[j, i, 0] = 0
                                __pyx_t_26 = __pyx_v_j;
                                __pyx_t_27 = __pyx_v_i;
                                __pyx_t_28 = 0;
                                *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_26 * __pyx_v_new_array.strides[0]) ) + __pyx_t_27 * __pyx_v_new_array.strides[1]) )) + __pyx_t_28)) )) = 0;
 139:                 else:
+140:                     new_array[j, i, 0] = rgb_array[i, j, ri]
                              /*else*/ {
                                __pyx_t_28 = __pyx_v_i;
                                __pyx_t_27 = __pyx_v_j;
                                __pyx_t_26 = __pyx_v_ri;
                                __pyx_t_29 = __pyx_v_j;
                                __pyx_t_30 = __pyx_v_i;
                                __pyx_t_31 = 0;
                                *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_29 * __pyx_v_new_array.strides[0]) ) + __pyx_t_30 * __pyx_v_new_array.strides[1]) )) + __pyx_t_31)) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_28 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_27 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_26 * __pyx_v_rgb_array.strides[2]) )));
                              }
                              __pyx_L33:;
 141: 
+142:                 if gi == -1:
                              __pyx_t_2 = ((__pyx_v_gi == -1L) != 0);
                              if (__pyx_t_2) {
/* … */
                                goto __pyx_L34;
                              }
+143:                     new_array[j, i, 1] = 0
                                __pyx_t_26 = __pyx_v_j;
                                __pyx_t_27 = __pyx_v_i;
                                __pyx_t_28 = 1;
                                *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_26 * __pyx_v_new_array.strides[0]) ) + __pyx_t_27 * __pyx_v_new_array.strides[1]) )) + __pyx_t_28)) )) = 0;
 144:                 else:
+145:                     new_array[j, i, 1] = rgb_array[i, j, gi]
                              /*else*/ {
                                __pyx_t_28 = __pyx_v_i;
                                __pyx_t_27 = __pyx_v_j;
                                __pyx_t_26 = __pyx_v_gi;
                                __pyx_t_31 = __pyx_v_j;
                                __pyx_t_30 = __pyx_v_i;
                                __pyx_t_29 = 1;
                                *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_31 * __pyx_v_new_array.strides[0]) ) + __pyx_t_30 * __pyx_v_new_array.strides[1]) )) + __pyx_t_29)) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_28 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_27 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_26 * __pyx_v_rgb_array.strides[2]) )));
                              }
                              __pyx_L34:;
 146: 
+147:                 if bi == -1:
                              __pyx_t_2 = ((__pyx_v_bi == -1L) != 0);
                              if (__pyx_t_2) {
/* … */
                                goto __pyx_L35;
                              }
+148:                     new_array[j, i, 2] = 0
                                __pyx_t_26 = __pyx_v_j;
                                __pyx_t_27 = __pyx_v_i;
                                __pyx_t_28 = 2;
                                *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_26 * __pyx_v_new_array.strides[0]) ) + __pyx_t_27 * __pyx_v_new_array.strides[1]) )) + __pyx_t_28)) )) = 0;
 149:                 else:
+150:                     new_array[j, i, 2] = rgb_array[i, j, bi]
                              /*else*/ {
                                __pyx_t_28 = __pyx_v_i;
                                __pyx_t_27 = __pyx_v_j;
                                __pyx_t_26 = __pyx_v_bi;
                                __pyx_t_29 = __pyx_v_j;
                                __pyx_t_30 = __pyx_v_i;
                                __pyx_t_31 = 2;
                                *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_29 * __pyx_v_new_array.strides[0]) ) + __pyx_t_30 * __pyx_v_new_array.strides[1]) )) + __pyx_t_31)) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_28 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_27 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_26 * __pyx_v_rgb_array.strides[2]) )));
                              }
                              __pyx_L35:;
                            }
                        }
                    }
                }
            }
        }
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   __builtin_expect(!!(x), 1)
            #define unlikely(x) __builtin_expect(!!(x), 0)
        #endif
      }
 151: 
+152:     return frombuffer(new_array, (width, height), 'RGB')
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_new_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_width); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_height); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  __pyx_t_13 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_12);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_12, function);
      __pyx_t_13 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_6, __pyx_t_17, __pyx_n_s_RGB};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
    PyObject *__pyx_temp[4] = {__pyx_t_4, __pyx_t_6, __pyx_t_17, __pyx_n_s_RGB};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_13, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_17);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_13, __pyx_t_17);
    __Pyx_INCREF(__pyx_n_s_RGB);
    __Pyx_GIVEREF(__pyx_n_s_RGB);
    PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_13, __pyx_n_s_RGB);
    __pyx_t_6 = 0;
    __pyx_t_17 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;
 153: 
 154: 
 155: 
 156: 
 157: @cython.boundscheck(False)
 158: @cython.wraparound(False)
 159: @cython.nonecheck(False)
 160: @cython.cdivision(True)
+161: cpdef create_horizontal_gradient_1d(
static PyObject *__pyx_pw_12PygameShader_4misc_3create_horizontal_gradient_1d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_12PygameShader_4misc_create_horizontal_gradient_1d(int __pyx_v_value, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_12PygameShader_4misc_create_horizontal_gradient_1d *__pyx_optional_args) {
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_AddTraceback("PygameShader.misc.create_horizontal_gradient_1d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_diff_, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_row, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_gradient, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_12PygameShader_4misc_3create_horizontal_gradient_1d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_12PygameShader_4misc_2create_horizontal_gradient_1d[] = "\n    CREATE AN ARRAY FILLED WITH A GRADIENT COLOR  \n    \n    :param value      : integer; Size of the gradient 1d width\n    :param start_color: tuple; Tuple containing the starting RGB color \n    :param end_color  : tuple; Tuple containing the RGB values of the final color\n    :return           : numpy.ndarray 2D array shape (w, 3) of type uint8 (unsigned char) \n     containing all the pixels \n    ";
static PyObject *__pyx_pw_12PygameShader_4misc_3create_horizontal_gradient_1d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_value;
  PyObject *__pyx_v_start_color = 0;
  PyObject *__pyx_v_end_color = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_horizontal_gradient_1d (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_start_color,&__pyx_n_s_end_color,0};
    PyObject* values[3] = {0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_12PygameShader_4misc_2create_horizontal_gradient_1d(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_value, PyObject *__pyx_v_start_color, PyObject *__pyx_v_end_color) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_horizontal_gradient_1d", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.start_color = __pyx_v_start_color;
  __pyx_t_2.end_color = __pyx_v_end_color;
  __pyx_t_1 = __pyx_f_12PygameShader_4misc_create_horizontal_gradient_1d(__pyx_v_value, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("PygameShader.misc.create_horizontal_gradient_1d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 162:         int value,
+163:         tuple start_color=(255, 0, 0),
  PyObject *__pyx_v_start_color = ((PyObject*)__pyx_tuple__3);
/* … */
  __pyx_tuple__3 = PyTuple_Pack(3, __pyx_int_255, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);
/* … */
    values[1] = ((PyObject*)__pyx_tuple__3);
+164:         tuple end_color=(0, 255, 0)
  PyObject *__pyx_v_end_color = ((PyObject*)__pyx_tuple__4);
  __Pyx_memviewslice __pyx_v_diff_ = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_row = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_rgb_gradient = { 0, 0, { 0 }, { 0 }, { 0 } };
  float __pyx_v_start[3];
  int __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("create_horizontal_gradient_1d", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_start_color = __pyx_optional_args->start_color;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_end_color = __pyx_optional_args->end_color;
      }
    }
  }
/* … */
    values[2] = ((PyObject*)__pyx_tuple__4);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start_color);
          if (value) { values[1] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_end_color);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_horizontal_gradient_1d") < 0)) __PYX_ERR(0, 161, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_value = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_value == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 162, __pyx_L3_error)
    __pyx_v_start_color = ((PyObject*)values[1]);
    __pyx_v_end_color = ((PyObject*)values[2]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("create_horizontal_gradient_1d", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 161, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("PygameShader.misc.create_horizontal_gradient_1d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start_color), (&PyTuple_Type), 1, "start_color", 1))) __PYX_ERR(0, 163, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_end_color), (&PyTuple_Type), 1, "end_color", 1))) __PYX_ERR(0, 164, __pyx_L1_error)
  __pyx_r = __pyx_pf_12PygameShader_4misc_2create_horizontal_gradient_1d(__pyx_self, __pyx_v_value, __pyx_v_start_color, __pyx_v_end_color);
/* … */
  __pyx_tuple__4 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_255, __pyx_int_0); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
 165: ):
 166:     """
 167:     CREATE AN ARRAY FILLED WITH A GRADIENT COLOR  
 168:     
 169:     :param value      : integer; Size of the gradient 1d width
 170:     :param start_color: tuple; Tuple containing the starting RGB color 
 171:     :param end_color  : tuple; Tuple containing the RGB values of the final color
 172:     :return           : numpy.ndarray 2D array shape (w, 3) of type uint8 (unsigned char) 
 173:      containing all the pixels 
 174:     """
 175:     cdef:
 176:         float [:] diff_ =  \
+177:             numpy.array(end_color, dtype=float32) - \
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_end_color);
  __Pyx_GIVEREF(__pyx_v_end_color);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_end_color);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_float(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 177, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_diff_ = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
+178:             numpy.array(start_color, dtype=float32)
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_start_color);
  __Pyx_GIVEREF(__pyx_v_start_color);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_start_color);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+179:         float [::1] row = numpy.arange(value, dtype=float32) / (value - 1.0)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_value - 1.0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dc_float(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 179, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_row = __pyx_t_7;
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
+180:         unsigned char [:, ::1] rgb_gradient = empty((value, 3), dtype=uint8)
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_3);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_unsigned_char(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_rgb_gradient = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
+181:         float [3] start = numpy.array(start_color, dtype=float32)
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_start_color);
  __Pyx_GIVEREF(__pyx_v_start_color);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_start_color);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (unlikely(__Pyx_carray_from_py_float(__pyx_t_4, __pyx_t_9, 3) < 0)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  memcpy(&(__pyx_v_start[0]), __pyx_t_9, sizeof(__pyx_v_start[0]) * (3));
+182:         int i=0
  __pyx_v_i = 0;
 183: 
+184:     with nogil:
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {
/* … */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }
+185:         for i in prange(value, schedule=SCHEDULE, num_threads=THREAD_NUMBER):
        __pyx_t_10 = __pyx_v_value;
        if ((1 == 0)) abort();
        {
            #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                #undef likely
                #undef unlikely
                #define likely(x)   (x)
                #define unlikely(x) (x)
            #endif
            __pyx_t_12 = (__pyx_t_10 - 0 + 1 - 1/abs(1)) / 1;
            if (__pyx_t_12 > 0)
            {
                #ifdef _OPENMP
                #pragma omp parallel
                #endif /* _OPENMP */
                {
                    #ifdef _OPENMP
                    #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) schedule(static) num_threads(8)
                    #endif /* _OPENMP */
                    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){
                        {
                            __pyx_v_i = (int)(0 + 1 * __pyx_t_11);
+186:                rgb_gradient[i, 0] = <unsigned char>(start[0] + row[i] * diff_[0])
                            __pyx_t_13 = __pyx_v_i;
                            __pyx_t_14 = 0;
                            __pyx_t_15 = __pyx_v_i;
                            __pyx_t_16 = 0;
                            *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb_gradient.data + __pyx_t_15 * __pyx_v_rgb_gradient.strides[0]) )) + __pyx_t_16)) )) = ((unsigned char)((__pyx_v_start[0]) + ((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_row.data) + __pyx_t_13)) ))) * (*((float *) ( /* dim=0 */ (__pyx_v_diff_.data + __pyx_t_14 * __pyx_v_diff_.strides[0]) ))))));
+187:                rgb_gradient[i, 1] = <unsigned char>(start[1] + row[i] * diff_[1])
                            __pyx_t_14 = __pyx_v_i;
                            __pyx_t_13 = 1;
                            __pyx_t_16 = __pyx_v_i;
                            __pyx_t_15 = 1;
                            *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb_gradient.data + __pyx_t_16 * __pyx_v_rgb_gradient.strides[0]) )) + __pyx_t_15)) )) = ((unsigned char)((__pyx_v_start[1]) + ((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_row.data) + __pyx_t_14)) ))) * (*((float *) ( /* dim=0 */ (__pyx_v_diff_.data + __pyx_t_13 * __pyx_v_diff_.strides[0]) ))))));
+188:                rgb_gradient[i, 2] = <unsigned char>(start[2] + row[i] * diff_[2])
                            __pyx_t_13 = __pyx_v_i;
                            __pyx_t_14 = 2;
                            __pyx_t_15 = __pyx_v_i;
                            __pyx_t_16 = 2;
                            *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb_gradient.data + __pyx_t_15 * __pyx_v_rgb_gradient.strides[0]) )) + __pyx_t_16)) )) = ((unsigned char)((__pyx_v_start[2]) + ((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_row.data) + __pyx_t_13)) ))) * (*((float *) ( /* dim=0 */ (__pyx_v_diff_.data + __pyx_t_14 * __pyx_v_diff_.strides[0]) ))))));
                        }
                    }
                }
            }
        }
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   __builtin_expect(!!(x), 1)
            #define unlikely(x) __builtin_expect(!!(x), 0)
        #endif
      }
 189: 
+190:     return asarray(rgb_gradient)
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_rgb_gradient, 2, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 191: 
 192: 
 193: 
 194: @cython.boundscheck(False)
 195: @cython.wraparound(False)
 196: @cython.nonecheck(False)
 197: @cython.cdivision(True)
+198: cpdef object horizontal_grad3d(
static PyObject *__pyx_pw_12PygameShader_4misc_5horizontal_grad3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_12PygameShader_4misc_horizontal_grad3d(int __pyx_v_width, int __pyx_v_height, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_12PygameShader_4misc_horizontal_grad3d *__pyx_optional_args) {
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_AddTraceback("PygameShader.misc.horizontal_grad3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_diff_, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_row, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_gradient, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_12PygameShader_4misc_5horizontal_grad3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_12PygameShader_4misc_4horizontal_grad3d[] = "\n    CREATE A GRADIENT FROM TWO COLORS\n\n    :param width      : integer; width of the new surface in pixels\n    :param height     : integer; height of the new surface in pixels\n    :param start_color: tuple; Value RGB, Starting color\n    :param end_color  : tuple; value RGB, ending color or final color\n    :return           : Surface; pygame.Surface format 24 bit \n    size width x height converted for fast blit\n    ";
static PyObject *__pyx_pw_12PygameShader_4misc_5horizontal_grad3d(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_width;
  int __pyx_v_height;
  PyObject *__pyx_v_start_color = 0;
  PyObject *__pyx_v_end_color = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("horizontal_grad3d (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_start_color,&__pyx_n_s_end_color,0};
    PyObject* values[4] = {0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_12PygameShader_4misc_4horizontal_grad3d(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_width, int __pyx_v_height, PyObject *__pyx_v_start_color, PyObject *__pyx_v_end_color) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("horizontal_grad3d", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2.__pyx_n = 2;
  __pyx_t_2.start_color = __pyx_v_start_color;
  __pyx_t_2.end_color = __pyx_v_end_color;
  __pyx_t_1 = __pyx_f_12PygameShader_4misc_horizontal_grad3d(__pyx_v_width, __pyx_v_height, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("PygameShader.misc.horizontal_grad3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
 199:         int width,
 200:         int height,
+201:         tuple start_color=(255, 0, 0),
  PyObject *__pyx_v_start_color = ((PyObject*)__pyx_tuple__3);
/* … */
    values[2] = ((PyObject*)__pyx_tuple__3);
+202:         tuple end_color=(0, 255, 0)
  PyObject *__pyx_v_end_color = ((PyObject*)__pyx_tuple__4);
  __Pyx_memviewslice __pyx_v_diff_ = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_row = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_rgb_gradient = { 0, 0, { 0 }, { 0 }, { 0 } };
  float __pyx_v_start[3];
  int __pyx_v_i;
  int __pyx_v_j;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("horizontal_grad3d", 0);
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_start_color = __pyx_optional_args->start_color;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_end_color = __pyx_optional_args->end_color;
      }
    }
  }
/* … */
    values[3] = ((PyObject*)__pyx_tuple__4);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        CYTHON_FALLTHROUGH;
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_width)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        CYTHON_FALLTHROUGH;
        case  1:
        if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_height)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("horizontal_grad3d", 0, 2, 4, 1); __PYX_ERR(0, 198, __pyx_L3_error)
        }
        CYTHON_FALLTHROUGH;
        case  2:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_start_color);
          if (value) { values[2] = value; kw_args--; }
        }
        CYTHON_FALLTHROUGH;
        case  3:
        if (kw_args > 0) {
          PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_end_color);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "horizontal_grad3d") < 0)) __PYX_ERR(0, 198, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        CYTHON_FALLTHROUGH;
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        CYTHON_FALLTHROUGH;
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_width = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L3_error)
    __pyx_v_height = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L3_error)
    __pyx_v_start_color = ((PyObject*)values[2]);
    __pyx_v_end_color = ((PyObject*)values[3]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("horizontal_grad3d", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 198, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("PygameShader.misc.horizontal_grad3d", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start_color), (&PyTuple_Type), 1, "start_color", 1))) __PYX_ERR(0, 201, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_end_color), (&PyTuple_Type), 1, "end_color", 1))) __PYX_ERR(0, 202, __pyx_L1_error)
  __pyx_r = __pyx_pf_12PygameShader_4misc_4horizontal_grad3d(__pyx_self, __pyx_v_width, __pyx_v_height, __pyx_v_start_color, __pyx_v_end_color);
 203: ):
 204:     """
 205:     CREATE A GRADIENT FROM TWO COLORS
 206: 
 207:     :param width      : integer; width of the new surface in pixels
 208:     :param height     : integer; height of the new surface in pixels
 209:     :param start_color: tuple; Value RGB, Starting color
 210:     :param end_color  : tuple; value RGB, ending color or final color
 211:     :return           : Surface; pygame.Surface format 24 bit 
 212:     size width x height converted for fast blit
 213:     """
 214:     cdef:
 215:         float [:] diff_ =  \
+216:             numpy.array(end_color, dtype=float32) - \
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_end_color);
  __Pyx_GIVEREF(__pyx_v_end_color);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_end_color);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_float(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 216, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_diff_ = __pyx_t_6;
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
+217:             numpy.array(start_color, dtype=float32)
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_v_start_color);
  __Pyx_GIVEREF(__pyx_v_start_color);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_start_color);
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 217, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+218:         float [::1] row = numpy.arange(width, dtype=float32) / (width - 1.0)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_float32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_width - 1.0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dc_float(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_row = __pyx_t_7;
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
+219:         unsigned char [:, :, ::1] rgb_gradient = empty((width, height, 3), dtype=uint8)
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_3);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 219, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_rgb_gradient = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
+220:         float [3] start = numpy.array(start_color, dtype=float32)
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_start_color);
  __Pyx_GIVEREF(__pyx_v_start_color);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_start_color);
  __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(__Pyx_carray_from_py_float(__pyx_t_4, __pyx_t_9, 3) < 0)) __PYX_ERR(0, 220, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  memcpy(&(__pyx_v_start[0]), __pyx_t_9, sizeof(__pyx_v_start[0]) * (3));
+221:         int i=0, j=0
  __pyx_v_i = 0;
  __pyx_v_j = 0;
 222: 
+223:     with nogil:
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      __Pyx_FastGIL_Remember();
      #endif
      /*try:*/ {
/* … */
      /*finally:*/ {
        /*normal exit:*/{
          #ifdef WITH_THREAD
          __Pyx_FastGIL_Forget();
          Py_BLOCK_THREADS
          #endif
          goto __pyx_L5;
        }
        __pyx_L5:;
      }
  }
+224:         for i in prange(width, schedule='static', num_threads=THREAD_NUMBER):
        __pyx_t_10 = __pyx_v_width;
        if ((1 == 0)) abort();
        {
            #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                #undef likely
                #undef unlikely
                #define likely(x)   (x)
                #define unlikely(x) (x)
            #endif
            __pyx_t_12 = (__pyx_t_10 - 0 + 1 - 1/abs(1)) / 1;
            if (__pyx_t_12 > 0)
            {
                #ifdef _OPENMP
                #pragma omp parallel
                #endif /* _OPENMP */
                {
                    #ifdef _OPENMP
                    #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) schedule(static) num_threads(8)
                    #endif /* _OPENMP */
                    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){
                        {
                            __pyx_v_i = (int)(0 + 1 * __pyx_t_11);
                            /* Initialize private variables to invalid values */
                            __pyx_v_j = ((int)0xbad0bad0);
+225:             for j in range(height):
                            __pyx_t_13 = __pyx_v_height;
                            __pyx_t_14 = __pyx_t_13;
                            for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
                              __pyx_v_j = __pyx_t_15;
+226:                rgb_gradient[i, j, 0] = <unsigned char>(start[0] + row[i] * diff_[0])
                              __pyx_t_16 = __pyx_v_i;
                              __pyx_t_17 = 0;
                              __pyx_t_18 = __pyx_v_i;
                              __pyx_t_19 = __pyx_v_j;
                              __pyx_t_20 = 0;
                              *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_gradient.data + __pyx_t_18 * __pyx_v_rgb_gradient.strides[0]) ) + __pyx_t_19 * __pyx_v_rgb_gradient.strides[1]) )) + __pyx_t_20)) )) = ((unsigned char)((__pyx_v_start[0]) + ((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_row.data) + __pyx_t_16)) ))) * (*((float *) ( /* dim=0 */ (__pyx_v_diff_.data + __pyx_t_17 * __pyx_v_diff_.strides[0]) ))))));
+227:                rgb_gradient[i, j, 1] = <unsigned char>(start[1] + row[i] * diff_[1])
                              __pyx_t_17 = __pyx_v_i;
                              __pyx_t_16 = 1;
                              __pyx_t_20 = __pyx_v_i;
                              __pyx_t_19 = __pyx_v_j;
                              __pyx_t_18 = 1;
                              *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_gradient.data + __pyx_t_20 * __pyx_v_rgb_gradient.strides[0]) ) + __pyx_t_19 * __pyx_v_rgb_gradient.strides[1]) )) + __pyx_t_18)) )) = ((unsigned char)((__pyx_v_start[1]) + ((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_row.data) + __pyx_t_17)) ))) * (*((float *) ( /* dim=0 */ (__pyx_v_diff_.data + __pyx_t_16 * __pyx_v_diff_.strides[0]) ))))));
+228:                rgb_gradient[i, j, 2] = <unsigned char>(start[2] + row[i] * diff_[2])
                              __pyx_t_16 = __pyx_v_i;
                              __pyx_t_17 = 2;
                              __pyx_t_18 = __pyx_v_i;
                              __pyx_t_19 = __pyx_v_j;
                              __pyx_t_20 = 2;
                              *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_gradient.data + __pyx_t_18 * __pyx_v_rgb_gradient.strides[0]) ) + __pyx_t_19 * __pyx_v_rgb_gradient.strides[1]) )) + __pyx_t_20)) )) = ((unsigned char)((__pyx_v_start[2]) + ((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_row.data) + __pyx_t_16)) ))) * (*((float *) ( /* dim=0 */ (__pyx_v_diff_.data + __pyx_t_17 * __pyx_v_diff_.strides[0]) ))))));
                            }
                        }
                    }
                }
            }
        }
        #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
            #undef likely
            #undef unlikely
            #define likely(x)   __builtin_expect(!!(x), 1)
            #define unlikely(x) __builtin_expect(!!(x), 0)
        #endif
      }
 229: 
+230:     return make_surface(asarray(rgb_gradient)).convert()
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_21 = __pyx_memoryview_fromslice(__pyx_v_rgb_gradient, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_22 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_22)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_22);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  __pyx_t_5 = (__pyx_t_22) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_22, __pyx_t_21) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5);
  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_convert); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 230, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;
 231: 
 232: 
 233: 
 234: @cython.boundscheck(False)
 235: @cython.wraparound(False)
 236: @cython.nonecheck(False)
 237: @cython.cdivision(True)
+238: cdef float color_dist_hsv(hsv hsv_1, hsv hsv_2)nogil:
static float __pyx_f_12PygameShader_4misc_color_dist_hsv(struct hsv __pyx_v_hsv_1, struct hsv __pyx_v_hsv_2) {
  float __pyx_r;
/* … */
  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
+239:     return (hsv_1.h - hsv_2.h) ** 2 + (hsv_1.s - hsv_2.s) ** 2 + (hsv_1.v - hsv_2.v) ** 2
  __pyx_r = ((powf((__pyx_v_hsv_1.h - __pyx_v_hsv_2.h), 2.0) + powf((__pyx_v_hsv_1.s - __pyx_v_hsv_2.s), 2.0)) + powf((__pyx_v_hsv_1.v - __pyx_v_hsv_2.v), 2.0));
  goto __pyx_L0;
 240: 
 241: 
 242: @cython.boundscheck(False)
 243: @cython.wraparound(False)
 244: @cython.nonecheck(False)
 245: @cython.cdivision(True)
+246: cdef float color_dist_hsl(hsl hsl_1, hsl hsl_2)nogil:
static float __pyx_f_12PygameShader_4misc_color_dist_hsl(struct hsl __pyx_v_hsl_1, struct hsl __pyx_v_hsl_2) {
  float __pyx_r;
/* … */
  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
+247:     return (hsl_1.h - hsl_2.h) ** 2 + (hsl_1.s - hsl_2.s) ** 2 + (hsl_1.l - hsl_2.l) ** 2
  __pyx_r = ((powf((__pyx_v_hsl_1.h - __pyx_v_hsl_2.h), 2.0) + powf((__pyx_v_hsl_1.s - __pyx_v_hsl_2.s), 2.0)) + powf((__pyx_v_hsl_1.l - __pyx_v_hsl_2.l), 2.0));
  goto __pyx_L0;
 248: 
 249: 
 250: @cython.boundscheck(False)
 251: @cython.wraparound(False)
 252: @cython.nonecheck(False)
 253: @cython.cdivision(True)
+254: cdef rgb color_diff_hsv(
static struct rgb __pyx_f_12PygameShader_4misc_color_diff_hsv(struct rgb __pyx_v_color0, __Pyx_memviewslice __pyx_v_palette_, Py_ssize_t __pyx_v_p_length) {
  float *__pyx_v_hsv_values;
  int __pyx_v_i;
  struct rgb __pyx_v_color1;
  struct hsv __pyx_v_hsv1;
  struct hsv __pyx_v_hsv2;
  float __pyx_v_minimum;
  int __pyx_v_found;
  struct rgb __pyx_r;
/* … */
  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
 255:         rgb color0,
 256:         float [:, :] palette_,
 257:         Py_ssize_t p_length
 258: )nogil:
 259:     """
 260:     FIND THE CLOSEST MATCH FOR A GIVEN COLOR (color0) FROM 
 261:     A COLOR PALETTE (palette_). 
 262:     
 263:     This method is using hsv space to find the closest color from the palette.
 264:     Each colors from the palette are compare with the HSV value of the given color
 265:     and the minimal difference between HSV values represent the closest match. 
 266:     
 267:     :param color0  : struct RGB containing the pixel color 
 268:     :param palette_: numpy.ndarray shape (w, 3) type float32 containing the palette colors RGB 
 269:     range [0 ... 255] 
 270:     :param p_length: integer; size of the given palette or number of colors
 271:     :return: struct RGB containing the new pixel values RGB 
 272:     """
 273: 
 274:     cdef:
 275: 
+276:         float * hsv_values = <float *> malloc(p_length * sizeof(float))
  __pyx_v_hsv_values = ((float *)malloc((__pyx_v_p_length * (sizeof(float)))));
 277:         int i
 278:         rgb color1
 279:         hsv hsv1, hsv2
 280:         float minimum
 281: 
 282: 
 283:     # THE RGB TO HSV VALUE NEVER CHANGE INSIDE THE LOOP
+284:     hsv1 = struct_rgb_to_hsv(
  __pyx_v_hsv1 = struct_rgb_to_hsv((((float)__pyx_v_color0.r) / ((float)255.0)), (((float)__pyx_v_color0.g) / ((float)255.0)), (((float)__pyx_v_color0.b) / ((float)255.0)));
 285:         <float>color0.r / <float>255.0,
 286:         <float>color0.g / <float>255.0,
 287:         <float>color0.b / <float>255.0)
 288: 
 289: 
+290:     for i in range(p_length):
  __pyx_t_1 = __pyx_v_p_length;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
 291: 
+292:         hsv2 = struct_rgb_to_hsv(
    __pyx_v_hsv2 = struct_rgb_to_hsv((((float)(*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) )))) / ((float)255.0)), (((float)(*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_6 * __pyx_v_palette_.strides[0]) ) + __pyx_t_7 * __pyx_v_palette_.strides[1]) )))) / ((float)255.0)), (((float)(*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) )))) / ((float)255.0)));
+293:             <float>palette_[ i, 0 ]/ <float>255.0,
    __pyx_t_4 = __pyx_v_i;
    __pyx_t_5 = 0;
+294:             <float>palette_[ i, 1 ]/ <float>255.0,
    __pyx_t_6 = __pyx_v_i;
    __pyx_t_7 = 1;
+295:             <float>palette_[ i, 2 ]/ <float>255.0)
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_9 = 2;
 296: 
+297:         hsv_values[i] = <float>color_dist_hsv(hsv1, hsv2)
    (__pyx_v_hsv_values[__pyx_v_i]) = ((float)__pyx_f_12PygameShader_4misc_color_dist_hsv(__pyx_v_hsv1, __pyx_v_hsv2));
  }
 298: 
+299:     minimum = <float>minf(hsv_values, p_length)
  __pyx_v_minimum = ((float)minf(__pyx_v_hsv_values, __pyx_v_p_length));
 300: 
+301:     cdef bint found = False
  __pyx_v_found = 0;
+302:     for i in range(p_length):
  __pyx_t_1 = __pyx_v_p_length;
  __pyx_t_2 = __pyx_t_1;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
+303:         if minimum == hsv_values[i]:
    __pyx_t_10 = ((__pyx_v_minimum == (__pyx_v_hsv_values[__pyx_v_i])) != 0);
    if (__pyx_t_10) {
/* … */
    }
  }
  __pyx_L6_break:;
+304:             found = True
      __pyx_v_found = 1;
+305:             break
      goto __pyx_L6_break;
 306: 
+307:     if found:
  __pyx_t_10 = (__pyx_v_found != 0);
  if (__pyx_t_10) {
/* … */
    goto __pyx_L8;
  }
+308:         color1.r = palette_[ i, 0 ]
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_8 = 0;
    __pyx_v_color1.r = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) )));
+309:         color1.g = palette_[ i, 1 ]
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_9 = 1;
    __pyx_v_color1.g = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) )));
+310:         color1.b = palette_[ i, 2 ]
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_8 = 2;
    __pyx_v_color1.b = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) )));
 311:     else:
+312:         color1.r = 0.0
  /*else*/ {
    __pyx_v_color1.r = 0.0;
+313:         color1.g = 0.
    __pyx_v_color1.g = 0.;
+314:         color1.b = 0.
    __pyx_v_color1.b = 0.;
  }
  __pyx_L8:;
 315: 
+316:     free(hsv_values)
  free(__pyx_v_hsv_values);
 317: 
+318:     return color1
  __pyx_r = __pyx_v_color1;
  goto __pyx_L0;
 319: 
 320: 
 321: 
 322: @cython.boundscheck(False)
 323: @cython.wraparound(False)
 324: @cython.nonecheck(False)
 325: @cython.cdivision(True)
+326: cdef rgb color_diff_hsl(
static struct rgb __pyx_f_12PygameShader_4misc_color_diff_hsl(struct rgb __pyx_v_color0, __Pyx_memviewslice __pyx_v_palette_, Py_ssize_t __pyx_v_p_length) {
  float *__pyx_v_hsl_values;
  int __pyx_v_i;
  struct rgb __pyx_v_color1;
  struct hsl __pyx_v_hsl1;
  struct hsl __pyx_v_hsl2;
  float __pyx_v_minimum;
  int __pyx_v_found;
  struct rgb __pyx_r;
/* … */
  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
 327:         rgb color0,
 328:         float [:, :] palette_,
 329:         Py_ssize_t p_length
 330: )nogil:
 331:     """
 332: 
 333:     FIND THE CLOSEST MATCH FOR A GIVEN COLOR (color0) FROM 
 334:     A COLOR PALETTE (palette_). 
 335:     
 336:     This method is using HSL color space to find the closest color from the palette.
 337:     Each colors from the palette are compare with the HSL values of the given color
 338:     and the minimal difference between HSL values represent the closest match. 
 339:     
 340:     :param color0  : struct RGB containing the pixel color 
 341:     :param palette_: numpy.ndarray shape (w, 3) type float32 containing the palette colors RGB 
 342:     range [0 ... 255] 
 343:     :param p_length: integer; size of the given palette or number of colors
 344:     :return: struct RGB containing the new pixel values RGB 
 345:     """
 346: 
 347:     cdef:
 348: 
+349:         float * hsl_values = <float *> malloc(p_length * sizeof(float))
  __pyx_v_hsl_values = ((float *)malloc((__pyx_v_p_length * (sizeof(float)))));
 350:         int i
 351:         rgb color1
 352:         hsl hsl1, hsl2
 353:         float minimum
 354: 
 355: 
 356:     # THE RGB TO HSL VALUE NEVER CHANGE INSIDE THE LOOP
+357:     hsl1 = struct_rgb_to_hsl(
  __pyx_v_hsl1 = struct_rgb_to_hsl((((float)__pyx_v_color0.r) / ((float)255.0)), (((float)__pyx_v_color0.g) / ((float)255.0)), (((float)__pyx_v_color0.b) / ((float)255.0)));
 358:         <float>color0.r / <float>255.0,
 359:         <float>color0.g / <float>255.0,
 360:         <float>color0.b / <float>255.0)
 361: 
+362:     for i in prange(p_length):
  __pyx_t_1 = __pyx_v_p_length;
  if ((1 == 0)) abort();
  {
      #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
          #undef likely
          #undef unlikely
          #define likely(x)   (x)
          #define unlikely(x) (x)
      #endif
      __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1;
      if (__pyx_t_3 > 0)
      {
          #ifdef _OPENMP
          #pragma omp parallel
          #endif /* _OPENMP */
          {
              #ifdef _OPENMP
              #pragma omp for lastprivate(__pyx_v_hsl2) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
              #endif /* _OPENMP */
              for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){
                  {
                      __pyx_v_i = (int)(0 + 1 * __pyx_t_2);
 363: 
+364:         hsl2 = struct_rgb_to_hsl(
                      __pyx_v_hsl2 = struct_rgb_to_hsl((((float)(*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) )))) / ((float)255.0)), (((float)(*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_6 * __pyx_v_palette_.strides[0]) ) + __pyx_t_7 * __pyx_v_palette_.strides[1]) )))) / ((float)255.0)), (((float)(*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) )))) / ((float)255.0)));
+365:             <float>palette_[ i, 0 ]/ <float>255.0,
                      __pyx_t_4 = __pyx_v_i;
                      __pyx_t_5 = 0;
+366:             <float>palette_[ i, 1 ]/ <float>255.0,
                      __pyx_t_6 = __pyx_v_i;
                      __pyx_t_7 = 1;
+367:             <float>palette_[ i, 2 ]/ <float>255.0)
                      __pyx_t_8 = __pyx_v_i;
                      __pyx_t_9 = 2;
 368: 
+369:         hsl_values[i] = <float>color_dist_hsl(hsl1, hsl2)
                      (__pyx_v_hsl_values[__pyx_v_i]) = ((float)__pyx_f_12PygameShader_4misc_color_dist_hsl(__pyx_v_hsl1, __pyx_v_hsl2));
                  }
              }
          }
      }
  }
  #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
      #undef likely
      #undef unlikely
      #define likely(x)   __builtin_expect(!!(x), 1)
      #define unlikely(x) __builtin_expect(!!(x), 0)
  #endif
 370: 
+371:     minimum = <float>minf(hsl_values, p_length)
  __pyx_v_minimum = ((float)minf(__pyx_v_hsl_values, __pyx_v_p_length));
 372: 
+373:     cdef bint found = False
  __pyx_v_found = 0;
 374: 
+375:     for i in range(p_length):
  __pyx_t_3 = __pyx_v_p_length;
  __pyx_t_2 = __pyx_t_3;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_2; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;
+376:         if minimum == hsl_values[i]:
    __pyx_t_11 = ((__pyx_v_minimum == (__pyx_v_hsl_values[__pyx_v_i])) != 0);
    if (__pyx_t_11) {
/* … */
    }
  }
  __pyx_L10_break:;
+377:             found = True
      __pyx_v_found = 1;
+378:             break
      goto __pyx_L10_break;
 379: 
+380:     if found:
  __pyx_t_11 = (__pyx_v_found != 0);
  if (__pyx_t_11) {
/* … */
    goto __pyx_L12;
  }
+381:         color1.r = palette_[ i, 0 ]
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_8 = 0;
    __pyx_v_color1.r = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) )));
+382:         color1.g = palette_[ i, 1 ]
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_9 = 1;
    __pyx_v_color1.g = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) )));
+383:         color1.b = palette_[ i, 2 ]
    __pyx_t_9 = __pyx_v_i;
    __pyx_t_8 = 2;
    __pyx_v_color1.b = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) )));
 384:     else:
+385:         color1.r = <float>0.0
  /*else*/ {
    __pyx_v_color1.r = ((float)0.0);
+386:         color1.g = <float>0.0
    __pyx_v_color1.g = ((float)0.0);
+387:         color1.b = <float>0.0
    __pyx_v_color1.b = ((float)0.0);
  }
  __pyx_L12:;
 388: 
+389:     free(hsl_values)
  free(__pyx_v_hsl_values);
 390: 
+391:     return color1
  __pyx_r = __pyx_v_color1;
  goto __pyx_L0;
 392: 
 393: @cython.boundscheck(False)
 394: @cython.wraparound(False)
 395: @cython.nonecheck(False)
 396: @cython.cdivision(True)
+397: cdef rgb close_color(
static struct rgb __pyx_f_12PygameShader_4misc_close_color(struct rgb __pyx_v_colors, __Pyx_memviewslice __pyx_v_palette_, Py_ssize_t __pyx_v_w) {
  int __pyx_v_i;
  float *__pyx_v_tmp_v;
  struct rgb __pyx_v_rgb_;
  float __pyx_v_v_min;
  int __pyx_v_s1;
  int __pyx_v_s2;
  struct hsv __pyx_v_color0_hsv;
  struct hsv __pyx_v_hsv1;
  struct hsv __pyx_v_hsv2;
  struct rgb __pyx_r;
/* … */
  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
 398:         rgb colors,
 399:         float [:, :] palette_,
 400:         Py_ssize_t w
 401: )nogil:
 402:     """
 403:     FIND THE NEAREST COLOR MATCHING A GIVEN COLOR 
 404:     
 405:     Iterate over a 2d color palette filled with RGB values (array shape, 
 406:     w, 3) type float32. The palette is not normalised and contains values 
 407:     in range [0...255] 
 408:     During the iteration, the given color is compare with the palette values 
 409:     subtracting each components and summed up to be able to find the smallest 
 410:     value. The original color 'colors' will be replaced with a new color
 411:     from the palette (new RGB components). 
 412:     This algorithm will work if the color palette contains unique RGB components
 413:     For palettes with duplicate color, the algorithm will select the first color 
 414:     corresponding to the sum of the RGB difference between each components
 415:     
 416:     :param colors  : struct RGB; float; Colors define with a struct type of data  
 417:     :param palette_: numpy.array; Palette containing the RGB color values range [0...255]  
 418:     :param w       : integer; size of the palette 
 419:     :return        : struct rgb containing the new RGB values close match from 
 420:     the given color  
 421:     """
 422: 
 423:     cdef:
 424:         int i
+425:         float * tmp_v    = <float *> malloc(w * sizeof(float))
  __pyx_v_tmp_v = ((float *)malloc((__pyx_v_w * (sizeof(float)))));
 426:         rgb rgb_
 427:         float v_min,
 428: 
 429:     # SUM ALL RGB DIFFERENCES
+430:     for i in prange(w):
  __pyx_t_1 = __pyx_v_w;
  if ((1 == 0)) abort();
  {
      #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
          #undef likely
          #undef unlikely
          #define likely(x)   (x)
          #define unlikely(x) (x)
      #endif
      __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1;
      if (__pyx_t_3 > 0)
      {
          #ifdef _OPENMP
          #pragma omp parallel
          #endif /* _OPENMP */
          {
              #ifdef _OPENMP
              #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
              #endif /* _OPENMP */
              for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){
                  {
                      __pyx_v_i = (int)(0 + 1 * __pyx_t_2);
+431:         tmp_v[ i ] = sqrt((
                      (__pyx_v_tmp_v[__pyx_v_i]) = sqrt(((powf((__pyx_v_colors.r - (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) )))), 2.0) + powf((__pyx_v_colors.g - (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_6 * __pyx_v_palette_.strides[0]) ) + __pyx_t_7 * __pyx_v_palette_.strides[1]) )))), 2.0)) + powf((__pyx_v_colors.b - (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) )))), 2.0)));
                  }
              }
          }
      }
  }
  #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
      #undef likely
      #undef unlikely
      #define likely(x)   __builtin_expect(!!(x), 1)
      #define unlikely(x) __builtin_expect(!!(x), 0)
  #endif
+432:             colors.r - palette_[ i, 0 ]) ** 2 + \
                      __pyx_t_4 = __pyx_v_i;
                      __pyx_t_5 = 0;
+433:            (colors.g - palette_[ i, 1 ]) ** 2 + \
                      __pyx_t_6 = __pyx_v_i;
                      __pyx_t_7 = 1;
+434:            (colors.b - palette_[ i, 2 ]) ** 2)
                      __pyx_t_8 = __pyx_v_i;
                      __pyx_t_9 = 2;
 435:     # THE MINIMUM VALUE IS THE CLOSEST RGB MATCH
+436:     v_min = <float> minf(tmp_v, w)
  __pyx_v_v_min = ((float)minf(__pyx_v_tmp_v, __pyx_v_w));
 437: 
 438: 
+439:     cdef int s1 = 0
  __pyx_v_s1 = 0;
+440:     cdef int s2 = 0
  __pyx_v_s2 = 0;
 441: 
 442:     # CHECK FIRST SOLUTION
+443:     for i in range(w):
  __pyx_t_3 = __pyx_v_w;
  __pyx_t_2 = __pyx_t_3;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_2; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;
+444:         if round_c(v_min) == round_c(tmp_v[i]):
    __pyx_t_11 = ((round(__pyx_v_v_min) == round((__pyx_v_tmp_v[__pyx_v_i]))) != 0);
    if (__pyx_t_11) {
/* … */
    }
  }
  __pyx_L10_break:;
+445:             s1 = i
      __pyx_v_s1 = __pyx_v_i;
+446:             break
      goto __pyx_L10_break;
 447: 
 448:     # CHECK FOR COLORS WITH SAME DISTANCE
+449:     for i in range(w):
  __pyx_t_3 = __pyx_v_w;
  __pyx_t_2 = __pyx_t_3;
  for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_2; __pyx_t_10+=1) {
    __pyx_v_i = __pyx_t_10;
+450:         if round_c(v_min) == round_c(tmp_v[i]):
    __pyx_t_11 = ((round(__pyx_v_v_min) == round((__pyx_v_tmp_v[__pyx_v_i]))) != 0);
    if (__pyx_t_11) {
/* … */
    }
  }
+451:             if i != s1:
      __pyx_t_11 = ((__pyx_v_i != __pyx_v_s1) != 0);
      if (__pyx_t_11) {
/* … */
      }
+452:                 s2 = i
        __pyx_v_s2 = __pyx_v_i;
 453: 
 454:     cdef:
 455:         hsv color0_hsv
 456:         hsv hsv1
 457:         hsv hsv2
 458: 
+459:     if s1!= 0 and s2 != 0:
  __pyx_t_12 = ((__pyx_v_s1 != 0) != 0);
  if (__pyx_t_12) {
  } else {
    __pyx_t_11 = __pyx_t_12;
    goto __pyx_L17_bool_binop_done;
  }
  __pyx_t_12 = ((__pyx_v_s2 != 0) != 0);
  __pyx_t_11 = __pyx_t_12;
  __pyx_L17_bool_binop_done:;
  if (__pyx_t_11) {
/* … */
    goto __pyx_L16;
  }
+460:         color0_hsv = struct_rgb_to_hsv(
    __pyx_v_color0_hsv = struct_rgb_to_hsv((__pyx_v_colors.r / ((float)255.0)), (__pyx_v_colors.g / ((float)255.0)), (__pyx_v_colors.b / ((float)255.0)));
 461:             colors.r/<float>255.0,
 462:             colors.g/<float>255.0,
 463:             colors.b/<float>255.0)
+464:         hsv1 = struct_rgb_to_hsv(
    __pyx_v_hsv1 = struct_rgb_to_hsv(((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) ))) / ((float)255.0)), ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_7 * __pyx_v_palette_.strides[0]) ) + __pyx_t_6 * __pyx_v_palette_.strides[1]) ))) / ((float)255.0)), ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_5 * __pyx_v_palette_.strides[0]) ) + __pyx_t_4 * __pyx_v_palette_.strides[1]) ))) / ((float)255.0)));
+465:             palette_[ s1, 0 ]/<float>255.0,
    __pyx_t_9 = __pyx_v_s1;
    __pyx_t_8 = 0;
+466:             palette_[ s1, 0 ]/<float>255.0,
    __pyx_t_7 = __pyx_v_s1;
    __pyx_t_6 = 0;
+467:             palette_[ s1, 0 ]/<float>255.0)
    __pyx_t_5 = __pyx_v_s1;
    __pyx_t_4 = 0;
+468:         hsv2 = struct_rgb_to_hsv(
    __pyx_v_hsv2 = struct_rgb_to_hsv(((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) ))) / ((float)255.0)), ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_6 * __pyx_v_palette_.strides[0]) ) + __pyx_t_7 * __pyx_v_palette_.strides[1]) ))) / ((float)255.0)), ((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) ))) / ((float)255.0)));
+469:             palette_[ s2, 0 ] / <float> 255.0,
    __pyx_t_4 = __pyx_v_s2;
    __pyx_t_5 = 0;
+470:             palette_[ s2, 0 ] / <float> 255.0,
    __pyx_t_6 = __pyx_v_s2;
    __pyx_t_7 = 0;
+471:             palette_[ s2, 0 ] / <float> 255.0)
    __pyx_t_8 = __pyx_v_s2;
    __pyx_t_9 = 0;
+472:         if (color0_hsv.h - hsv1.h) ** 2 <  (color0_hsv.h - hsv2.h) ** 2:
    __pyx_t_11 = ((powf((__pyx_v_color0_hsv.h - __pyx_v_hsv1.h), 2.0) < powf((__pyx_v_color0_hsv.h - __pyx_v_hsv2.h), 2.0)) != 0);
    if (__pyx_t_11) {
/* … */
      goto __pyx_L19;
    }
+473:             i = s1
      __pyx_v_i = __pyx_v_s1;
 474:         else:
+475:             i = s2
    /*else*/ {
      __pyx_v_i = __pyx_v_s2;
    }
    __pyx_L19:;
 476:     else:
+477:         i = s1
  /*else*/ {
    __pyx_v_i = __pyx_v_s1;
  }
  __pyx_L16:;
 478: 
+479:     rgb_.r = palette_[ i, 0 ]
  __pyx_t_9 = __pyx_v_i;
  __pyx_t_8 = 0;
  __pyx_v_rgb_.r = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) )));
+480:     rgb_.g = palette_[ i, 1 ]
  __pyx_t_8 = __pyx_v_i;
  __pyx_t_9 = 1;
  __pyx_v_rgb_.g = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_8 * __pyx_v_palette_.strides[0]) ) + __pyx_t_9 * __pyx_v_palette_.strides[1]) )));
+481:     rgb_.b = palette_[ i, 2 ]
  __pyx_t_9 = __pyx_v_i;
  __pyx_t_8 = 2;
  __pyx_v_rgb_.b = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_9 * __pyx_v_palette_.strides[0]) ) + __pyx_t_8 * __pyx_v_palette_.strides[1]) )));
 482: 
+483:     return rgb_
  __pyx_r = __pyx_v_rgb_;
  goto __pyx_L0;
 484: 
 485: 
 486: 
 487: 
 488: @cython.boundscheck(False)
 489: @cython.wraparound(False)
 490: @cython.nonecheck(False)
 491: @cython.cdivision(True)
+492: cdef rgb use_palette(
static struct rgb __pyx_f_12PygameShader_4misc_use_palette(struct rgb __pyx_v_colors, __Pyx_memviewslice __pyx_v_palette_, Py_ssize_t __pyx_v_w) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  float *__pyx_v_v_red;
  float *__pyx_v_v_green;
  float *__pyx_v_v_blue;
  float __pyx_v_r_min;
  float __pyx_v_g_min;
  float __pyx_v_b_min;
  struct rgb __pyx_v_rgb_;
  struct rgb __pyx_r;
/* … */
  /* function exit code */
  __pyx_L0:;
  return __pyx_r;
}
 493:         rgb colors,
 494:         float [:, :] palette_,
 495:         Py_ssize_t w
 496: )nogil:
 497:     """
 498:     PICKED RGB VALUES FROM A GIVEN PALETTE TO MATCH A GIVEN COLOR
 499:     ** PAINTING MODE **
 500: 
 501:     Picked r, g, b values from a palette by going through every
 502:     elements and picking the closest match for each channels.
 503:     The final color will be not necessary match a color from the palette
 504:     but will have instead, a palette values from each channels.
 505: 
 506: 
 507:     :param colors  : struct; Contains RGB values integer values in range [0..255]
 508:     :param palette_: numpy.array shape (w, 3) type float32 containing RGB colors values
 509:     :param w       : Size of the palette or number of colors available
 510:     :return        : Return a color RGB containing colors from the palette.
 511:     """
 512: 
 513:     cdef:
 514:         int i, j, k
+515:         float * v_red   = <float *> malloc(w * sizeof(float))
  __pyx_v_v_red = ((float *)malloc((__pyx_v_w * (sizeof(float)))));
+516:         float * v_green = <float *> malloc(w * sizeof(float))
  __pyx_v_v_green = ((float *)malloc((__pyx_v_w * (sizeof(float)))));
+517:         float * v_blue  = <float *> malloc(w * sizeof(float))
  __pyx_v_v_blue = ((float *)malloc((__pyx_v_w * (sizeof(float)))));
 518:         float r_min, g_min, b_min
 519:         rgb rgb_
 520: 
 521:     # GO THROUGH EACH CHANNELS OF THE PALETTE AND
 522:     # SUBTRACT VALUES.
+523:     for i in prange(w):
  __pyx_t_1 = __pyx_v_w;
  if ((1 == 0)) abort();
  {
      #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
          #undef likely
          #undef unlikely
          #define likely(x)   (x)
          #define unlikely(x) (x)
      #endif
      __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1;
      if (__pyx_t_3 > 0)
      {
          #ifdef _OPENMP
          #pragma omp parallel
          #endif /* _OPENMP */
          {
              #ifdef _OPENMP
              #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
              #endif /* _OPENMP */
              for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){
                  {
                      __pyx_v_i = (int)(0 + 1 * __pyx_t_2);
+524:         v_red[i]   = abs_c(colors.r - palette_[i, 0] )
                      __pyx_t_4 = __pyx_v_i;
                      __pyx_t_5 = 0;
                      (__pyx_v_v_red[__pyx_v_i]) = fabs((__pyx_v_colors.r - (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) )))));
+525:         v_green[i] = abs_c(colors.g - palette_[i, 1] )
                      __pyx_t_5 = __pyx_v_i;
                      __pyx_t_4 = 1;
                      (__pyx_v_v_green[__pyx_v_i]) = fabs((__pyx_v_colors.g - (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_5 * __pyx_v_palette_.strides[0]) ) + __pyx_t_4 * __pyx_v_palette_.strides[1]) )))));
+526:         v_blue[i]  = abs_c(colors.b - palette_[i, 2] )
                      __pyx_t_4 = __pyx_v_i;
                      __pyx_t_5 = 2;
                      (__pyx_v_v_blue[__pyx_v_i]) = fabs((__pyx_v_colors.b - (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) )))));
                  }
              }
          }
      }
  }
  #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
      #undef likely
      #undef unlikely
      #define likely(x)   __builtin_expect(!!(x), 1)
      #define unlikely(x) __builtin_expect(!!(x), 0)
  #endif
 527: 
 528:     # THE FINAL R, G, B VALUES WILL BE A PICKED
 529:     # COLOR FROM EACH CHANNELS CLOSE TO THE ORIGINAL PIXEL
 530:     # VALUE
+531:     r_min = <float> minf(v_red, w)
  __pyx_v_r_min = ((float)minf(__pyx_v_v_red, __pyx_v_w));
+532:     g_min = <float> minf(v_green, w)
  __pyx_v_g_min = ((float)minf(__pyx_v_v_green, __pyx_v_w));
+533:     b_min = <float> minf(v_blue, w)
  __pyx_v_b_min = ((float)minf(__pyx_v_v_blue, __pyx_v_w));
 534: 
 535:     # FIND A RED COLOR FROM THE PALETTE
 536:     # CLOSE TO THE ORIGINAL RED VALUE
+537:     for i in range(w):
  __pyx_t_3 = __pyx_v_w;
  __pyx_t_2 = __pyx_t_3;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_2; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;
+538:         if v_red[i] == r_min:
    __pyx_t_7 = (((__pyx_v_v_red[__pyx_v_i]) == __pyx_v_r_min) != 0);
    if (__pyx_t_7) {
/* … */
    }
  }
  __pyx_L10_break:;
+539:             break
      goto __pyx_L10_break;
 540: 
 541:     # FIND A GREEN COLOR FROM THE PALETTE
 542:     # CLOSE TO THE ORIGINAL GREEN VALUE
+543:     for j in range(w):
  __pyx_t_3 = __pyx_v_w;
  __pyx_t_2 = __pyx_t_3;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_2; __pyx_t_6+=1) {
    __pyx_v_j = __pyx_t_6;
+544:         if v_green[j] == g_min:
    __pyx_t_7 = (((__pyx_v_v_green[__pyx_v_j]) == __pyx_v_g_min) != 0);
    if (__pyx_t_7) {
/* … */
    }
  }
  __pyx_L13_break:;
+545:             break
      goto __pyx_L13_break;
 546: 
 547:     # FIND A BLUE COLOR FROM THE PALETTE
 548:     # CLOSE TO THE ORIGINAL BLUE VALUE
+549:     for k in range(w):
  __pyx_t_3 = __pyx_v_w;
  __pyx_t_2 = __pyx_t_3;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_2; __pyx_t_6+=1) {
    __pyx_v_k = __pyx_t_6;
+550:         if v_blue[k] == b_min:
    __pyx_t_7 = (((__pyx_v_v_blue[__pyx_v_k]) == __pyx_v_b_min) != 0);
    if (__pyx_t_7) {
/* … */
    }
  }
  __pyx_L16_break:;
+551:             break
      goto __pyx_L16_break;
 552: 
+553:     rgb_.r = palette_[i, 0]
  __pyx_t_5 = __pyx_v_i;
  __pyx_t_4 = 0;
  __pyx_v_rgb_.r = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_5 * __pyx_v_palette_.strides[0]) ) + __pyx_t_4 * __pyx_v_palette_.strides[1]) )));
+554:     rgb_.g = palette_[j, 1]
  __pyx_t_4 = __pyx_v_j;
  __pyx_t_5 = 1;
  __pyx_v_rgb_.g = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_4 * __pyx_v_palette_.strides[0]) ) + __pyx_t_5 * __pyx_v_palette_.strides[1]) )));
+555:     rgb_.b = palette_[k, 2]
  __pyx_t_5 = __pyx_v_k;
  __pyx_t_4 = 2;
  __pyx_v_rgb_.b = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_palette_.data + __pyx_t_5 * __pyx_v_palette_.strides[0]) ) + __pyx_t_4 * __pyx_v_palette_.strides[1]) )));
 556: 
+557:     free(v_red)
  free(__pyx_v_v_red);
+558:     free(v_green)
  free(__pyx_v_v_green);
+559:     free(v_blue)
  free(__pyx_v_v_blue);
 560: 
+561:     return rgb_
  __pyx_r = __pyx_v_rgb_;
  goto __pyx_L0;
 562: