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: shader.c
+0001: # cython: binding=False, boundscheck=False, wraparound=False, nonecheck=False, cdivision=True,
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0002: # cython: optimize.use_switch=True
0003: # encoding: utf-8
0004:
0005: """
0006: GNU GENERAL PUBLIC LICENSE
0007: Version 3, 29 June 2007
0008:
0009: Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
0010: Everyone is permitted to copy and distribute verbatim copies
0011: of this license document, but changing it is not allowed.
0012:
0013: Copyright Yoann Berenguer
0014: """
0015:
0016:
0017: """
0018: Version 1.0.1 (yank)
0019: + new cartoon effect added to library for offline surface processing. This shader cannot
0020: be used in real time due to the amount of transformation.
0021:
0022: Version 1.0.2 same than 1.0.1
0023: + new cartoon effect added to library for offline surface processing. This shader cannot
0024: be used in real time due to the amount of transformation.
0025:
0026:
0027: Version 1.0.3
0028: ++ New transition effect (blend effect)
0029:
0030: ++ BUG CORRECTED IN rgb_split
0031: # unsigned char [:] red = numpy.empty(z, uint8, order='C')
0032: # unsigned char [:] green = numpy.empty(z, uint8, order='C')
0033: # unsigned char [:] blue = numpy.empty(z, uint8, order='C')
0034: # TO
0035: # unsigned char [:] red = numpy.zeros(z, uint8, order='C')
0036: # unsigned char [:] green = numpy.zeros(z, uint8, order='C')
0037: # unsigned char [:] blue = numpy.zeros(z, uint8, order='C')
0038:
0039: # ++ Predator mode has now a blending mode
0040: # int blend = pygame.BLEND_RGB_ADD
0041: # Also change declaration in pxd file and pyx bint inv_colormap and bint fast
0042: cpdef predator_vision(object surface_, unsigned int sobel_threshold=*,
0043: unsigned int bpf_threshold=*, unsigned int bloom_threshold=*,
0044: bint inv_colormap=*, bint fast=*, int blend=*)
0045:
0046: ++ Renamed all the methods with a quicker and easier name to remember
0047:
0048: ++ corrected algos swirl and swirl2 (divided r by r_max)
0049:
0050: ++ new algorithm dirt_lens effect
0051:
0052: ++ Change brightness and brightness_exclude, no change if shift_ == 0
0053:
0054: ++ Changed /corrected bug with color_reduction algorithm.
0055:
0056: ++ Added Dithering algorithm
0057: ++ Added Color_palette
0058: ++ added bilateral filter
0059: ++ added emboss filter
0060: ++ pixelation
0061: ++ convert to 27 colors
0062: ++ spectrum surface
0063: ++ horizontal gradient (unit misc.pyx)
0064:
0065: ++ create misc.pxd file
0066:
0067: """
0068:
0069: """
0070: Version 1.0.4
0071:
0072: ++ bug correction for rgb_to_int
0073: now returning the correct value --> return 65536 * red + 256 * green + blue
0074:
0075: """
0076:
+0077: __VERSION__ = "1.0.4"
if (PyDict_SetItem(__pyx_d, __pyx_n_s_VERSION, __pyx_kp_s_1_0_4) < 0) __PYX_ERR(1, 77, __pyx_L1_error)
0078:
+0079: import warnings
__pyx_t_1 = __Pyx_Import(__pyx_n_s_warnings, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_1) < 0) __PYX_ERR(1, 79, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0080:
+0081: warnings.filterwarnings("ignore", category=FutureWarning)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_filterwarnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_category, __pyx_builtin_FutureWarning) < 0) __PYX_ERR(1, 81, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__52, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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_tuple__52 = PyTuple_Pack(1, __pyx_n_s_ignore); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(1, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__52); __Pyx_GIVEREF(__pyx_tuple__52);
+0082: warnings.filterwarnings("ignore", category=RuntimeWarning)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_warnings); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_filterwarnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_category, __pyx_builtin_RuntimeWarning) < 0) __PYX_ERR(1, 82, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__52, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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;
+0083: warnings.filterwarnings("ignore", category=ImportWarning)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_filterwarnings); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_category, __pyx_builtin_ImportWarning) < 0) __PYX_ERR(1, 83, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__52, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0084:
+0085: try:
{ /*try:*/ { /* … */ } __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; goto __pyx_L7_try_end; __pyx_L2_error:; __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; /* … */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L7_try_end:; }
+0086: import numpy
__pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 86, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_numpy, __pyx_t_1) < 0) __PYX_ERR(1, 86, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0087: from numpy import empty, uint8, int16, float32, asarray, linspace, \
__pyx_t_1 = PyList_New(12); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_empty); __Pyx_GIVEREF(__pyx_n_s_empty); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_empty); __Pyx_INCREF(__pyx_n_s_uint8); __Pyx_GIVEREF(__pyx_n_s_uint8); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_uint8); __Pyx_INCREF(__pyx_n_s_int16); __Pyx_GIVEREF(__pyx_n_s_int16); PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_int16); __Pyx_INCREF(__pyx_n_s_float32); __Pyx_GIVEREF(__pyx_n_s_float32); PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_float32); __Pyx_INCREF(__pyx_n_s_asarray); __Pyx_GIVEREF(__pyx_n_s_asarray); PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_asarray); __Pyx_INCREF(__pyx_n_s_linspace); __Pyx_GIVEREF(__pyx_n_s_linspace); PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_linspace); __Pyx_INCREF(__pyx_n_s_ascontiguousarray); __Pyx_GIVEREF(__pyx_n_s_ascontiguousarray); PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_ascontiguousarray); __Pyx_INCREF(__pyx_n_s_zeros); __Pyx_GIVEREF(__pyx_n_s_zeros); PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_s_zeros); __Pyx_INCREF(__pyx_n_s_uint16); __Pyx_GIVEREF(__pyx_n_s_uint16); PyList_SET_ITEM(__pyx_t_1, 8, __pyx_n_s_uint16); __Pyx_INCREF(__pyx_n_s_uint32); __Pyx_GIVEREF(__pyx_n_s_uint32); PyList_SET_ITEM(__pyx_t_1, 9, __pyx_n_s_uint32); __Pyx_INCREF(__pyx_n_s_int32); __Pyx_GIVEREF(__pyx_n_s_int32); PyList_SET_ITEM(__pyx_t_1, 10, __pyx_n_s_int32); __Pyx_INCREF(__pyx_n_s_int8); __Pyx_GIVEREF(__pyx_n_s_int8); PyList_SET_ITEM(__pyx_t_1, 11, __pyx_n_s_int8); __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_empty, __pyx_t_1) < 0) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_uint8, __pyx_t_1) < 0) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_int16); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_int16, __pyx_t_1) < 0) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_float32); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_float32, __pyx_t_1) < 0) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_asarray, __pyx_t_1) < 0) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_linspace); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_linspace, __pyx_t_1) < 0) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ascontiguousarray, __pyx_t_1) < 0) __PYX_ERR(1, 88, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_zeros, __pyx_t_1) < 0) __PYX_ERR(1, 88, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_uint16); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_uint16, __pyx_t_1) < 0) __PYX_ERR(1, 88, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_uint32); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_uint32, __pyx_t_1) < 0) __PYX_ERR(1, 88, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_int32); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_int32, __pyx_t_1) < 0) __PYX_ERR(1, 88, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_int8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 87, __pyx_L2_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_int8, __pyx_t_1) < 0) __PYX_ERR(1, 88, __pyx_L2_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0088: ascontiguousarray, zeros, uint16, uint32, int32, int8
+0089: except ImportError:
__pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_7) { __Pyx_AddTraceback("shader", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(1, 89, __pyx_L4_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_3);
+0090: raise ImportError("\n<numpy> library is missing on your system."
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 90, __pyx_L4_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(1, 90, __pyx_L4_except_error) } goto __pyx_L4_except_error; __pyx_L4_except_error:; /* … */ __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_s_numpy_library_is_missing_on_you); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(1, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__53); __Pyx_GIVEREF(__pyx_tuple__53);
0091: "\nTry: \n C:\\pip install numpy on a window command prompt.")
0092:
0093: cimport numpy as np
0094:
+0095: try:
{ /*try:*/ { /* … */ } }
0096: cimport cython
0097: from cython.parallel cimport prange
0098:
0099: except ImportError:
0100: raise ImportError("\n<cython> library is missing on your system."
0101: "\nTry: \n C:\\pip install cython on a window command prompt.")
0102:
0103: # PYGAME IS REQUIRED
+0104: try:
{ /*try:*/ { /* … */ } __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; goto __pyx_L21_try_end; __pyx_L16_error:; __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; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L21_try_end:; }
+0105: import pygame
__pyx_t_3 = __Pyx_Import(__pyx_n_s_pygame, 0, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 105, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pygame, __pyx_t_3) < 0) __PYX_ERR(1, 105, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0106: from pygame import Color, Surface, SRCALPHA, RLEACCEL, BufferProxy, HWACCEL, HWSURFACE, \
__pyx_t_3 = PyList_New(13); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_Color); __Pyx_GIVEREF(__pyx_n_s_Color); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Color); __Pyx_INCREF(__pyx_n_s_Surface); __Pyx_GIVEREF(__pyx_n_s_Surface); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_Surface); __Pyx_INCREF(__pyx_n_s_SRCALPHA); __Pyx_GIVEREF(__pyx_n_s_SRCALPHA); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_SRCALPHA); __Pyx_INCREF(__pyx_n_s_RLEACCEL); __Pyx_GIVEREF(__pyx_n_s_RLEACCEL); PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_RLEACCEL); __Pyx_INCREF(__pyx_n_s_BufferProxy); __Pyx_GIVEREF(__pyx_n_s_BufferProxy); PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_BufferProxy); __Pyx_INCREF(__pyx_n_s_HWACCEL); __Pyx_GIVEREF(__pyx_n_s_HWACCEL); PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_HWACCEL); __Pyx_INCREF(__pyx_n_s_HWSURFACE); __Pyx_GIVEREF(__pyx_n_s_HWSURFACE); PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_HWSURFACE); __Pyx_INCREF(__pyx_n_s_QUIT); __Pyx_GIVEREF(__pyx_n_s_QUIT); PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_QUIT); __Pyx_INCREF(__pyx_n_s_K_SPACE); __Pyx_GIVEREF(__pyx_n_s_K_SPACE); PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_K_SPACE); __Pyx_INCREF(__pyx_n_s_BLEND_RGB_ADD); __Pyx_GIVEREF(__pyx_n_s_BLEND_RGB_ADD); PyList_SET_ITEM(__pyx_t_3, 9, __pyx_n_s_BLEND_RGB_ADD); __Pyx_INCREF(__pyx_n_s_Rect); __Pyx_GIVEREF(__pyx_n_s_Rect); PyList_SET_ITEM(__pyx_t_3, 10, __pyx_n_s_Rect); __Pyx_INCREF(__pyx_n_s_BLEND_RGB_MAX); __Pyx_GIVEREF(__pyx_n_s_BLEND_RGB_MAX); PyList_SET_ITEM(__pyx_t_3, 11, __pyx_n_s_BLEND_RGB_MAX); __Pyx_INCREF(__pyx_n_s_BLEND_RGB_MIN); __Pyx_GIVEREF(__pyx_n_s_BLEND_RGB_MIN); PyList_SET_ITEM(__pyx_t_3, 12, __pyx_n_s_BLEND_RGB_MIN); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pygame, __pyx_t_3, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Color); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Color, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Surface, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_SRCALPHA); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_SRCALPHA, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_RLEACCEL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_RLEACCEL, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BufferProxy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BufferProxy, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_HWACCEL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_HWACCEL, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_HWSURFACE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_HWSURFACE, __pyx_t_3) < 0) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_QUIT); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_QUIT, __pyx_t_3) < 0) __PYX_ERR(1, 107, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_K_SPACE); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_K_SPACE, __pyx_t_3) < 0) __PYX_ERR(1, 107, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BLEND_RGB_ADD, __pyx_t_3) < 0) __PYX_ERR(1, 107, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Rect); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Rect, __pyx_t_3) < 0) __PYX_ERR(1, 107, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BLEND_RGB_MAX); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BLEND_RGB_MAX, __pyx_t_3) < 0) __PYX_ERR(1, 107, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_BLEND_RGB_MIN); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 106, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_BLEND_RGB_MIN, __pyx_t_3) < 0) __PYX_ERR(1, 107, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0107: QUIT, K_SPACE, BLEND_RGB_ADD, Rect, BLEND_RGB_MAX, BLEND_RGB_MIN
+0108: from pygame.surfarray import pixels3d, array_alpha, pixels_alpha, array3d, \
__pyx_t_1 = PyList_New(9); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_pixels3d); __Pyx_GIVEREF(__pyx_n_s_pixels3d); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pixels3d); __Pyx_INCREF(__pyx_n_s_array_alpha); __Pyx_GIVEREF(__pyx_n_s_array_alpha); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_array_alpha); __Pyx_INCREF(__pyx_n_s_pixels_alpha); __Pyx_GIVEREF(__pyx_n_s_pixels_alpha); PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_pixels_alpha); __Pyx_INCREF(__pyx_n_s_array3d); __Pyx_GIVEREF(__pyx_n_s_array3d); PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_array3d); __Pyx_INCREF(__pyx_n_s_make_surface); __Pyx_GIVEREF(__pyx_n_s_make_surface); PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_make_surface); __Pyx_INCREF(__pyx_n_s_blit_array); __Pyx_GIVEREF(__pyx_n_s_blit_array); PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_blit_array); __Pyx_INCREF(__pyx_n_s_pixels_red); __Pyx_GIVEREF(__pyx_n_s_pixels_red); PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_pixels_red); __Pyx_INCREF(__pyx_n_s_pixels_green); __Pyx_GIVEREF(__pyx_n_s_pixels_green); PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_s_pixels_green); __Pyx_INCREF(__pyx_n_s_pixels_blue); __Pyx_GIVEREF(__pyx_n_s_pixels_blue); PyList_SET_ITEM(__pyx_t_1, 8, __pyx_n_s_pixels_blue); __pyx_t_3 = __Pyx_Import(__pyx_n_s_pygame_surfarray, __pyx_t_1, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels3d, __pyx_t_1) < 0) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_array_alpha); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_alpha, __pyx_t_1) < 0) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_pixels_alpha); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels_alpha, __pyx_t_1) < 0) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_array3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array3d, __pyx_t_1) < 0) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_surface, __pyx_t_1) < 0) __PYX_ERR(1, 109, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_blit_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_blit_array, __pyx_t_1) < 0) __PYX_ERR(1, 109, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_pixels_red); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels_red, __pyx_t_1) < 0) __PYX_ERR(1, 109, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_pixels_green); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels_green, __pyx_t_1) < 0) __PYX_ERR(1, 110, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_pixels_blue); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 108, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pixels_blue, __pyx_t_1) < 0) __PYX_ERR(1, 110, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0109: make_surface, blit_array, pixels_red, \
0110: pixels_green, pixels_blue
+0111: from pygame.image import frombuffer, fromstring, tostring
__pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_frombuffer); __Pyx_GIVEREF(__pyx_n_s_frombuffer); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_frombuffer); __Pyx_INCREF(__pyx_n_s_fromstring); __Pyx_GIVEREF(__pyx_n_s_fromstring); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_fromstring); __Pyx_INCREF(__pyx_n_s_tostring); __Pyx_GIVEREF(__pyx_n_s_tostring); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_tostring); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pygame_image, __pyx_t_3, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_frombuffer, __pyx_t_3) < 0) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fromstring, __pyx_t_3) < 0) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_tostring); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_tostring, __pyx_t_3) < 0) __PYX_ERR(1, 111, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0112: from pygame.math import Vector2
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 112, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_Vector2); __Pyx_GIVEREF(__pyx_n_s_Vector2); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Vector2); __pyx_t_3 = __Pyx_Import(__pyx_n_s_pygame_math, __pyx_t_1, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 112, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Vector2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 112, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Vector2, __pyx_t_1) < 0) __PYX_ERR(1, 112, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0113: from pygame import _freetype
__pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_freetype); __Pyx_GIVEREF(__pyx_n_s_freetype); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_freetype); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pygame, __pyx_t_3, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 113, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_freetype); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 113, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_freetype, __pyx_t_3) < 0) __PYX_ERR(1, 113, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0114: from pygame._freetype import STYLE_STRONG, STYLE_NORMAL
__pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 114, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_STYLE_STRONG); __Pyx_GIVEREF(__pyx_n_s_STYLE_STRONG); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_STYLE_STRONG); __Pyx_INCREF(__pyx_n_s_STYLE_NORMAL); __Pyx_GIVEREF(__pyx_n_s_STYLE_NORMAL); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_STYLE_NORMAL); __pyx_t_3 = __Pyx_Import(__pyx_n_s_pygame__freetype, __pyx_t_1, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 114, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_STYLE_STRONG); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 114, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_STYLE_STRONG, __pyx_t_1) < 0) __PYX_ERR(1, 114, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_STYLE_NORMAL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 114, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_STYLE_NORMAL, __pyx_t_1) < 0) __PYX_ERR(1, 114, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0115: from pygame.transform import scale, smoothscale, rotate, scale2x
__pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_scale); __Pyx_GIVEREF(__pyx_n_s_scale); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_scale); __Pyx_INCREF(__pyx_n_s_smoothscale); __Pyx_GIVEREF(__pyx_n_s_smoothscale); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_smoothscale); __Pyx_INCREF(__pyx_n_s_rotate); __Pyx_GIVEREF(__pyx_n_s_rotate); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_rotate); __Pyx_INCREF(__pyx_n_s_scale2x); __Pyx_GIVEREF(__pyx_n_s_scale2x); PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_scale2x); __pyx_t_1 = __Pyx_Import(__pyx_n_s_pygame_transform, __pyx_t_3, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_scale); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_scale, __pyx_t_3) < 0) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_smoothscale, __pyx_t_3) < 0) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_rotate); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_rotate, __pyx_t_3) < 0) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_scale2x); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_scale2x, __pyx_t_3) < 0) __PYX_ERR(1, 115, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0116: from pygame.pixelcopy import array_to_surface
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 116, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_array_to_surface); __Pyx_GIVEREF(__pyx_n_s_array_to_surface); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_array_to_surface); __pyx_t_3 = __Pyx_Import(__pyx_n_s_pygame_pixelcopy, __pyx_t_1, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 116, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_array_to_surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 116, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array_to_surface, __pyx_t_1) < 0) __PYX_ERR(1, 116, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0117:
+0118: except ImportError:
__pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_7) { __Pyx_AddTraceback("shader", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(1, 118, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_2);
+0119: raise ImportError("\n<Pygame> library is missing on your system."
__pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ImportError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 119, __pyx_L18_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(1, 119, __pyx_L18_except_error) } goto __pyx_L18_except_error; __pyx_L18_except_error:; /* … */ __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_Pygame_library_is_missing_on_yo); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(1, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__54); __Pyx_GIVEREF(__pyx_tuple__54);
0120: "\nTry: \n C:\\pip install pygame on a window command prompt.")
0121:
+0122: try:
{ /*try:*/ { /* … */ } }
0123: cimport cython
0124: from cython.parallel cimport prange
0125: from cpython cimport PyObject_CallFunctionObjArgs, PyObject, \
0126: PyList_SetSlice, PyObject_HasAttr, PyObject_IsInstance, \
0127: PyObject_CallMethod, PyObject_CallObject
0128: from cpython.dict cimport PyDict_DelItem, PyDict_Clear, PyDict_GetItem, PyDict_SetItem, \
0129: PyDict_Values, PyDict_Keys, PyDict_Items
0130: from cpython.list cimport PyList_Append, PyList_GetItem, PyList_Size, PyList_SetItem
0131: from cpython.object cimport PyObject_SetAttr
0132:
0133: except ImportError:
0134: raise ImportError("\n<cython> library is missing on your system."
0135: "\nTry: \n C:\\pip install cython on a window command prompt.")
0136:
+0137: from PygameShader.gaussianBlur5x5 import canny_blur5x5_surface24_c
__pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_canny_blur5x5_surface24_c); __Pyx_GIVEREF(__pyx_n_s_canny_blur5x5_surface24_c); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_canny_blur5x5_surface24_c); __pyx_t_1 = __Pyx_Import(__pyx_n_s_PygameShader_gaussianBlur5x5, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_canny_blur5x5_surface24_c); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_canny_blur5x5_surface24_c, __pyx_t_2) < 0) __PYX_ERR(1, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0138: from PygameShader.misc cimport color_diff_hsv, color_diff_hsl, close_color
0139:
0140: from libc.stdlib cimport rand, malloc
0141: from libc.math cimport sqrt, atan2, sin, cos, nearbyint, exp, pow, floor
0142: from libc.stdlib cimport malloc, free
0143: from libc.math cimport round as round_c
0144:
0145: from libc.stdio cimport printf
0146:
+0147: cdef float M_PI = 3.14159265358979323846
__pyx_v_6shader_M_PI = 3.14159265358979323846;
+0148: cdef float M_PI2 =3.14159265358979323846/2.0
__pyx_v_6shader_M_PI2 = (3.14159265358979323846 / 2.0);
+0149: cdef float M_2PI =2 * 3.14159265358979323846
__pyx_v_6shader_M_2PI = (2.0 * 3.14159265358979323846);
0150:
+0151: cdef float RAD_TO_DEG=<float>(180.0/M_PI)
__pyx_v_6shader_RAD_TO_DEG = ((float)(180.0 / __pyx_v_6shader_M_PI));
+0152: cdef float DEG_TO_RAD=<float>(M_PI/180.0)
__pyx_v_6shader_DEG_TO_RAD = ((float)(__pyx_v_6shader_M_PI / 180.0));
0153:
+0154: cdef float C1 = <float>7.0/<float>16.0
__pyx_v_6shader_C1 = (((float)7.0) / ((float)16.0));
+0155: cdef float C2 = <float>3.0/<float>16.0
__pyx_v_6shader_C2 = (((float)3.0) / ((float)16.0));
+0156: cdef float C3 = <float>5.0/<float>16.0
__pyx_v_6shader_C3 = (((float)5.0) / ((float)16.0));
+0157: cdef float C4 = <float>1.0/<float>16.0
__pyx_v_6shader_C4 = (((float)1.0) / ((float)16.0));
0158:
+0159: cdef int THREADS = 8
__pyx_v_6shader_THREADS = 8;
0160:
0161: DEF HALF = 1.0/2.0
0162: DEF ONE_THIRD = 1.0/3.0
0163: DEF ONE_FOURTH = 1.0/4.0
0164: DEF ONE_FIFTH = 1.0/5.0
0165: DEF ONE_SIXTH = 1.0/6.0
0166: DEF ONE_SEVENTH = 1.0/7.0
0167: DEF ONE_HEIGHT = 1.0/8.0
0168: DEF ONE_NINTH = 1.0/9.0
0169: DEF ONE_TENTH = 1.0/10.0
0170: DEF ONE_ELEVENTH = 1.0/11.0
0171: DEF ONE_TWELVE = 1.0/12.0
0172: DEF ONE_32 = 1.0/32.0
0173: DEF ONE_64 = 1.0/64.0
0174: DEF ONE_128 = 1.0/128.0
0175: DEF ONE_255 = 1.0/255.0
0176: DEF ONE_360 = 1.0/360.0
0177: DEF TWO_THIRD = 2.0/3.0
0178:
0179: cdef float[360] COS_TABLE
0180: cdef float[360] SIN_TABLE
0181: cdef int ANGLE
+0182: for ANGLE in range(0, 360):
for (__pyx_t_7 = 0; __pyx_t_7 < 0x168; __pyx_t_7+=1) { __pyx_v_6shader_ANGLE = __pyx_t_7;
+0183: COS_TABLE[ANGLE] = <float>cos(<float>(ANGLE * DEG_TO_RAD))
(__pyx_v_6shader_COS_TABLE[__pyx_v_6shader_ANGLE]) = ((float)cos(((float)(__pyx_v_6shader_ANGLE * __pyx_v_6shader_DEG_TO_RAD))));
+0184: SIN_TABLE[ANGLE] = <float>sin(<float>(ANGLE * DEG_TO_RAD))
(__pyx_v_6shader_SIN_TABLE[__pyx_v_6shader_ANGLE]) = ((float)sin(((float)(__pyx_v_6shader_ANGLE * __pyx_v_6shader_DEG_TO_RAD)))); }
0185:
+0186: COLORS_CPC64 = numpy.array(
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_t_32 = PyTuple_New(1); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_32, 0, __pyx_t_33); __pyx_t_33 = 0; /* … */ __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_32, __pyx_t_33); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 186, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_COLORS_CPC64, __pyx_t_30) < 0) __PYX_ERR(1, 186, __pyx_L1_error) __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
+0187: [[0, 0, 0],
__pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_1, 2, __pyx_int_0); /* … */ __pyx_t_33 = PyList_New(27); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_33, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_33, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); PyList_SET_ITEM(__pyx_t_33, 2, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyList_SET_ITEM(__pyx_t_33, 3, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyList_SET_ITEM(__pyx_t_33, 4, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyList_SET_ITEM(__pyx_t_33, 5, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyList_SET_ITEM(__pyx_t_33, 6, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyList_SET_ITEM(__pyx_t_33, 7, __pyx_t_13); __Pyx_GIVEREF(__pyx_t_14); PyList_SET_ITEM(__pyx_t_33, 8, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_15); PyList_SET_ITEM(__pyx_t_33, 9, __pyx_t_15); __Pyx_GIVEREF(__pyx_t_16); PyList_SET_ITEM(__pyx_t_33, 10, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_17); PyList_SET_ITEM(__pyx_t_33, 11, __pyx_t_17); __Pyx_GIVEREF(__pyx_t_18); PyList_SET_ITEM(__pyx_t_33, 12, __pyx_t_18); __Pyx_GIVEREF(__pyx_t_19); PyList_SET_ITEM(__pyx_t_33, 13, __pyx_t_19); __Pyx_GIVEREF(__pyx_t_20); PyList_SET_ITEM(__pyx_t_33, 14, __pyx_t_20); __Pyx_GIVEREF(__pyx_t_21); PyList_SET_ITEM(__pyx_t_33, 15, __pyx_t_21); __Pyx_GIVEREF(__pyx_t_22); PyList_SET_ITEM(__pyx_t_33, 16, __pyx_t_22); __Pyx_GIVEREF(__pyx_t_23); PyList_SET_ITEM(__pyx_t_33, 17, __pyx_t_23); __Pyx_GIVEREF(__pyx_t_24); PyList_SET_ITEM(__pyx_t_33, 18, __pyx_t_24); __Pyx_GIVEREF(__pyx_t_25); PyList_SET_ITEM(__pyx_t_33, 19, __pyx_t_25); __Pyx_GIVEREF(__pyx_t_26); PyList_SET_ITEM(__pyx_t_33, 20, __pyx_t_26); __Pyx_GIVEREF(__pyx_t_27); PyList_SET_ITEM(__pyx_t_33, 21, __pyx_t_27); __Pyx_GIVEREF(__pyx_t_28); PyList_SET_ITEM(__pyx_t_33, 22, __pyx_t_28); __Pyx_GIVEREF(__pyx_t_29); PyList_SET_ITEM(__pyx_t_33, 23, __pyx_t_29); __Pyx_GIVEREF(__pyx_t_30); PyList_SET_ITEM(__pyx_t_33, 24, __pyx_t_30); __Pyx_GIVEREF(__pyx_t_31); PyList_SET_ITEM(__pyx_t_33, 25, __pyx_t_31); __Pyx_GIVEREF(__pyx_t_32); PyList_SET_ITEM(__pyx_t_33, 26, __pyx_t_32); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
+0188: [0, 0, 128],
__pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_3, 2, __pyx_int_128);
+0189: [0, 0, 255],
__pyx_t_8 = PyList_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_8, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_8, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_8, 2, __pyx_int_255);
+0190: [128, 0, 0],
__pyx_t_9 = PyList_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_9, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_9, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_9, 2, __pyx_int_0);
+0191: [128, 0, 128],
__pyx_t_10 = PyList_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_10, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_10, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_10, 2, __pyx_int_128);
+0192: [128, 0, 255],
__pyx_t_11 = PyList_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_11, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_11, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_11, 2, __pyx_int_255);
+0193: [255, 0, 0],
__pyx_t_12 = PyList_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_12, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_12, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_12, 2, __pyx_int_0);
+0194: [255, 0, 128],
__pyx_t_13 = PyList_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_13, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_13, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_13, 2, __pyx_int_128);
+0195: [255, 0, 255],
__pyx_t_14 = PyList_New(3); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_14, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_14, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_14, 2, __pyx_int_255);
+0196: [0, 128, 0],
__pyx_t_15 = PyList_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_15, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_15, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_15, 2, __pyx_int_0);
+0197: [0, 128, 128],
__pyx_t_16 = PyList_New(3); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_16, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_16, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_16, 2, __pyx_int_128);
+0198: [0, 128, 255],
__pyx_t_17 = PyList_New(3); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_17, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_17, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_17, 2, __pyx_int_255);
+0199: [128, 128, 0],
__pyx_t_18 = PyList_New(3); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_18, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_18, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_18, 2, __pyx_int_0);
+0200: [128, 128, 128],
__pyx_t_19 = PyList_New(3); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_19, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_19, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_19, 2, __pyx_int_128);
+0201: [128, 128, 255],
__pyx_t_20 = PyList_New(3); if (unlikely(!__pyx_t_20)) __PYX_ERR(1, 201, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_20, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_20, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_20, 2, __pyx_int_255);
+0202: [255, 128, 0],
__pyx_t_21 = PyList_New(3); if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_21, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_21, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_21, 2, __pyx_int_0);
+0203: [255, 128, 128],
__pyx_t_22 = PyList_New(3); if (unlikely(!__pyx_t_22)) __PYX_ERR(1, 203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_22, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_22, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_22, 2, __pyx_int_128);
+0204: [255, 128, 255],
__pyx_t_23 = PyList_New(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(1, 204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_23); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_23, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_23, 1, __pyx_int_128); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_23, 2, __pyx_int_255);
+0205: [0, 255, 0],
__pyx_t_24 = PyList_New(3); if (unlikely(!__pyx_t_24)) __PYX_ERR(1, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_24, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_24, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_24, 2, __pyx_int_0);
+0206: [0, 255, 128],
__pyx_t_25 = PyList_New(3); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_25); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_25, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_25, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_25, 2, __pyx_int_128);
+0207: [0, 255, 255],
__pyx_t_26 = PyList_New(3); if (unlikely(!__pyx_t_26)) __PYX_ERR(1, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_26); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_26, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_26, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_26, 2, __pyx_int_255);
+0208: [128, 255, 0],
__pyx_t_27 = PyList_New(3); if (unlikely(!__pyx_t_27)) __PYX_ERR(1, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_27); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_27, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_27, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_27, 2, __pyx_int_0);
+0209: [128, 255, 128],
__pyx_t_28 = PyList_New(3); if (unlikely(!__pyx_t_28)) __PYX_ERR(1, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_28); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_28, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_28, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_28, 2, __pyx_int_128);
+0210: [128, 255, 255],
__pyx_t_29 = PyList_New(3); if (unlikely(!__pyx_t_29)) __PYX_ERR(1, 210, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_29, 0, __pyx_int_128); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_29, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_29, 2, __pyx_int_255);
+0211: [255, 255, 0],
__pyx_t_30 = PyList_New(3); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_30, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_30, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_30, 2, __pyx_int_0);
+0212: [255, 255, 128],
__pyx_t_31 = PyList_New(3); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_31, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_31, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_128); __Pyx_GIVEREF(__pyx_int_128); PyList_SET_ITEM(__pyx_t_31, 2, __pyx_int_128);
+0213: [255, 255, 255]], dtype=numpy.uint8)
__pyx_t_32 = PyList_New(3); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_32, 0, __pyx_int_255); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_32, 1, __pyx_int_255); __Pyx_INCREF(__pyx_int_255); __Pyx_GIVEREF(__pyx_int_255); PyList_SET_ITEM(__pyx_t_32, 2, __pyx_int_255); /* … */ __pyx_t_33 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_GetModuleGlobalName(__pyx_t_31, __pyx_n_s_numpy); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_31, __pyx_n_s_uint8); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0; if (PyDict_SetItem(__pyx_t_33, __pyx_n_s_dtype, __pyx_t_30) < 0) __PYX_ERR(1, 213, __pyx_L1_error) __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
0214:
0215: cdef:
+0216: float [:, :] COLORS_CPC64_C = numpy.divide(COLORS_CPC64, 255.0).astype(dtype=float32)
__Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_n_s_numpy); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_n_s_divide); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_n_s_COLORS_CPC64); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __pyx_t_32 = PyTuple_New(2); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_GIVEREF(__pyx_t_30); PyTuple_SET_ITEM(__pyx_t_32, 0, __pyx_t_30); __Pyx_INCREF(__pyx_float_255_0); __Pyx_GIVEREF(__pyx_float_255_0); PyTuple_SET_ITEM(__pyx_t_32, 1, __pyx_float_255_0); __pyx_t_30 = 0; __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_33, __pyx_t_32, NULL); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_n_s_astype); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __pyx_t_30 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_float32); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); if (PyDict_SetItem(__pyx_t_30, __pyx_n_s_dtype, __pyx_t_33) < 0) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_32, __pyx_empty_tuple, __pyx_t_30); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __pyx_t_34 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_33, PyBUF_WRITABLE); if (unlikely(!__pyx_t_34.memview)) __PYX_ERR(1, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_COLORS_CPC64_C, 1); __pyx_v_6shader_COLORS_CPC64_C = __pyx_t_34; __pyx_t_34.memview = NULL; __pyx_t_34.data = NULL;
0217:
0218:
0219:
0220: # todo BILATERAL FILTER (CHECK project spritesheetstudio tools) + PIXELATE and PIXEL
0221: # BLOCKS
0222: # TODO FUNCTION TESTING IMAGE
0223: # TODO ADD HSV
0224:
0225:
0226:
+0227: cpdef inline void rgb_to_bgr(object surface_):
static PyObject *__pyx_pw_6shader_1rgb_to_bgr(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_rgb_to_bgr(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_bgr", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.rgb_to_bgr", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_1rgb_to_bgr(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_rgb_to_bgr[] = " \n SHADER RGB to BGR\n \n Convert your game display from RGB to BGR format\n This algorithm can also be used to transform pygame texture in the equivalent bgr format\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface.\n\n e.g:\n rgb_to_bgr(surface)\n\n :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with or \n without per-pixel transparency / alpha channel)\n :return : void\n "; static PyObject *__pyx_pw_6shader_1rgb_to_bgr(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_bgr (wrapper)", 0); __pyx_r = __pyx_pf_6shader_rgb_to_bgr(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_rgb_to_bgr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_bgr", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_rgb_to_bgr(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 227, __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("shader.rgb_to_bgr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0228: """
0229: SHADER RGB to BGR
0230:
0231: Convert your game display from RGB to BGR format
0232: This algorithm can also be used to transform pygame texture in the equivalent bgr format
0233:
0234: * The changes are automatically applied inplace to the surface you do not need to create a
0235: new surface.
0236:
0237: e.g:
0238: rgb_to_bgr(surface)
0239:
0240: :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with or
0241: without per-pixel transparency / alpha channel)
0242: :return : void
0243: """
+0244: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0245: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 244, __pyx_L1_error) } } #endif
0246:
+0247: shader_rgb_to_bgr_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 247, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_rgb_to_bgr_inplace_c(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0248:
0249:
+0250: cpdef inline void rgb_to_brg(object surface_):
static PyObject *__pyx_pw_6shader_3rgb_to_brg(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_rgb_to_brg(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_brg", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.rgb_to_brg", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_3rgb_to_brg(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_2rgb_to_brg[] = "\n SHADER RGB TO BRG\n\n Convert your game display from RGB to BRG format.\n This algorithm can also be used to transform pygame texture in the equivalent BRG format\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface.\n \n e.g:\n rgb_to_brg(surface)\n\n :param surface_: Pygame surface or display surface compatible (image 24-32 bit with or without \n per-pixel transparency / alpha channel)\n :return: void \n "; static PyObject *__pyx_pw_6shader_3rgb_to_brg(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_brg (wrapper)", 0); __pyx_r = __pyx_pf_6shader_2rgb_to_brg(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_2rgb_to_brg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_brg", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_rgb_to_brg(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 250, __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("shader.rgb_to_brg", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0251: """
0252: SHADER RGB TO BRG
0253:
0254: Convert your game display from RGB to BRG format.
0255: This algorithm can also be used to transform pygame texture in the equivalent BRG format
0256:
0257: * The changes are automatically applied inplace to the surface you do not need to create a
0258: new surface.
0259:
0260: e.g:
0261: rgb_to_brg(surface)
0262:
0263: :param surface_: Pygame surface or display surface compatible (image 24-32 bit with or without
0264: per-pixel transparency / alpha channel)
0265: :return: void
0266: """
+0267: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 267, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0268: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 267, __pyx_L1_error) } } #endif
0269:
+0270: shader_rgb_to_brg_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 270, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_rgb_to_brg_inplace_c(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0271:
+0272: cpdef inline void greyscale(object surface_):
static PyObject *__pyx_pw_6shader_5greyscale(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_greyscale(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("greyscale", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.greyscale", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_5greyscale(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_4greyscale[] = "\n SHADER GRAYSCALE (CONSERVE LUMINOSITY)\n\n This shader transform the game display on a grayscale video game effect\n \n * This shader can also be applied to pygame textures/surface to transform them into\n an equivalent grayscale model\n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface.\n\n e.g:\n greyscale(surface)\n\n :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with \n or without per-pixel transparency / alpha channel)\n :return : void\n \n "; static PyObject *__pyx_pw_6shader_5greyscale(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("greyscale (wrapper)", 0); __pyx_r = __pyx_pf_6shader_4greyscale(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_4greyscale(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("greyscale", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_greyscale(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 272, __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("shader.greyscale", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0273: """
0274: SHADER GRAYSCALE (CONSERVE LUMINOSITY)
0275:
0276: This shader transform the game display on a grayscale video game effect
0277:
0278: * This shader can also be applied to pygame textures/surface to transform them into
0279: an equivalent grayscale model
0280: * The changes are automatically applied inplace to the surface you do not need to create a
0281: new surface.
0282:
0283: e.g:
0284: greyscale(surface)
0285:
0286: :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with
0287: or without per-pixel transparency / alpha channel)
0288: :return : void
0289:
0290: """
+0291: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 291, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0292: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 291, __pyx_L1_error) } } #endif
0293:
+0294: shader_greyscale_luminosity24_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 294, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_greyscale_luminosity24_inplace_c(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0295:
0296:
+0297: cpdef inline void sepia(object surface_):
static PyObject *__pyx_pw_6shader_7sepia(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_sepia(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sepia", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.sepia", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_7sepia(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_6sepia[] = "\n SHADER SEPIA MODEL\n\n Transform your video game into an equivalent sepia model\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface.\n\n e.g:\n sepia(surface)\n\n\n :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with \n or without per-pixel transparency / alpha channel)\n :return: : void\n "; static PyObject *__pyx_pw_6shader_7sepia(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sepia (wrapper)", 0); __pyx_r = __pyx_pf_6shader_6sepia(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_6sepia(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sepia", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_sepia(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 297, __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("shader.sepia", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0298: """
0299: SHADER SEPIA MODEL
0300:
0301: Transform your video game into an equivalent sepia model
0302:
0303: * The changes are automatically applied inplace to the surface you do not need to create a
0304: new surface.
0305:
0306: e.g:
0307: sepia(surface)
0308:
0309:
0310: :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with
0311: or without per-pixel transparency / alpha channel)
0312: :return: : void
0313: """
+0314: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 314, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0315: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 315, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 314, __pyx_L1_error) } } #endif
0316:
+0317: shader_sepia24_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 317, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_sepia24_inplace_c(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0318:
0319:
0320: @cython.boundscheck(False)
0321: @cython.wraparound(False)
0322: @cython.nonecheck(False)
0323: @cython.cdivision(True)
+0324: cdef inline void median_fast(
static CYTHON_INLINE void __pyx_f_6shader_median_fast(PyObject *__pyx_v_surface_, struct __pyx_opt_args_6shader_median_fast *__pyx_optional_args) { unsigned short __pyx_v_kernel_size_ = ((unsigned short)2); unsigned short __pyx_v_reduce_factor_ = ((unsigned short)1); PyObject *__pyx_v_surface_cp = NULL; int __pyx_v_w; int __pyx_v_h; __Pyx_memviewslice __pyx_v_surface_cp_arr = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_i; int __pyx_v_j; __Pyx_memviewslice __pyx_v_org_surface = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_fast", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_reduce_factor_ = __pyx_optional_args->reduce_factor_; } } } /* … */ /* function exit code */ goto __pyx_L0; __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_8); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_WriteUnraisable("shader.median_fast", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_surface_cp); __PYX_XDEC_MEMVIEW(&__pyx_v_surface_cp_arr, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_org_surface, 1); __Pyx_RefNannyFinishContext(); }
0325: object surface_,
0326: unsigned short int kernel_size_=2,
0327: unsigned short int reduce_factor_=1
0328: ):
0329: """
0330: This function cannot be called directly from python script (cdef)
0331:
0332: :param surface_: pygame.surface; Surface compatible 24-32 bit
0333: :param kernel_size_: integer; size of the kernel
0334: :param reduce_factor_: integer; value of 1 divide the image by 2, value of 2 div the image by 4
0335: :return: void
0336: """
0337:
+0338: surface_cp = surface_.copy()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_surface_cp = __pyx_t_1; __pyx_t_1 = 0;
0339: cdef:
0340: int w, h
+0341: w, h = surface_cp.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_cp, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 341, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 341, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 341, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 341, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 341, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
0342:
+0343: surface_cp = smoothscale(surface_cp, (w >> reduce_factor_, h >> reduce_factor_))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_w >> __pyx_v_reduce_factor_)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_h >> __pyx_v_reduce_factor_)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_surface_cp, __pyx_t_8}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_surface_cp, __pyx_t_8}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_v_surface_cp); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_surface_cp, __pyx_t_1); __pyx_t_1 = 0;
0344:
0345: cdef:
+0346: unsigned char [:, :, :] surface_cp_arr = pixels3d(surface_cp)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_surface_cp) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_surface_cp); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 346, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_surface_cp_arr = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
0347: int i, j
+0348: unsigned char[:, :, :] org_surface = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 348, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_org_surface = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
0349:
+0350: shader_median_filter24_inplace_c(surface_cp_arr, kernel_size_)
__pyx_t_10.__pyx_n = 1; __pyx_t_10.kernel_size_ = __pyx_v_kernel_size_; __pyx_f_6shader_shader_median_filter24_inplace_c(__pyx_v_surface_cp_arr, &__pyx_t_10);
+0351: surface_cp_arr = scale_array24_c(surface_cp_arr, w, h)
__pyx_t_11 = __pyx_f_6shader_scale_array24_c(__pyx_v_surface_cp_arr, __pyx_v_w, __pyx_v_h); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 351, __pyx_L1_error)
__PYX_XDEC_MEMVIEW(&__pyx_v_surface_cp_arr, 1);
__pyx_v_surface_cp_arr = __pyx_t_11;
__pyx_t_11.memview = NULL;
__pyx_t_11.data = NULL;
0352:
+0353: 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_L7; } __pyx_L7:; } }
+0354: for i in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_7 = __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_12 = (__pyx_t_7 - 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) /* … */ __pyx_t_7 = __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_12 = (__pyx_t_7 - 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(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_12; __pyx_t_6++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_6); /* Initialize private variables to invalid values */ __pyx_v_j = ((int)0xbad0bad0);
+0355: for j in range(h):
__pyx_t_13 = __pyx_v_h; __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;
+0356: org_surface[i, j, 0] = surface_cp_arr[i, j, 0]
__pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 0; __pyx_t_19 = __pyx_v_i; __pyx_t_20 = __pyx_v_j; __pyx_t_21 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_org_surface.data + __pyx_t_19 * __pyx_v_org_surface.strides[0]) ) + __pyx_t_20 * __pyx_v_org_surface.strides[1]) ) + __pyx_t_21 * __pyx_v_org_surface.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_surface_cp_arr.data + __pyx_t_16 * __pyx_v_surface_cp_arr.strides[0]) ) + __pyx_t_17 * __pyx_v_surface_cp_arr.strides[1]) ) + __pyx_t_18 * __pyx_v_surface_cp_arr.strides[2]) )));
+0357: org_surface[i, j, 1] = surface_cp_arr[i, j, 1]
__pyx_t_18 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_16 = 1; __pyx_t_21 = __pyx_v_i; __pyx_t_20 = __pyx_v_j; __pyx_t_19 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_org_surface.data + __pyx_t_21 * __pyx_v_org_surface.strides[0]) ) + __pyx_t_20 * __pyx_v_org_surface.strides[1]) ) + __pyx_t_19 * __pyx_v_org_surface.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_surface_cp_arr.data + __pyx_t_18 * __pyx_v_surface_cp_arr.strides[0]) ) + __pyx_t_17 * __pyx_v_surface_cp_arr.strides[1]) ) + __pyx_t_16 * __pyx_v_surface_cp_arr.strides[2]) )));
+0358: org_surface[i, j, 2] = surface_cp_arr[i, j, 2]
__pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 2; __pyx_t_19 = __pyx_v_i; __pyx_t_20 = __pyx_v_j; __pyx_t_21 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_org_surface.data + __pyx_t_19 * __pyx_v_org_surface.strides[0]) ) + __pyx_t_20 * __pyx_v_org_surface.strides[1]) ) + __pyx_t_21 * __pyx_v_org_surface.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_surface_cp_arr.data + __pyx_t_16 * __pyx_v_surface_cp_arr.strides[0]) ) + __pyx_t_17 * __pyx_v_surface_cp_arr.strides[1]) ) + __pyx_t_18 * __pyx_v_surface_cp_arr.strides[2]) ))); } } } } } } #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 }
0359:
0360:
+0361: cpdef inline void median(
static PyObject *__pyx_pw_6shader_9median(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_median(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_median *__pyx_optional_args) { unsigned short __pyx_v_kernel_size_ = ((unsigned short)2); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_AddTraceback("shader.median", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_9median(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_8median[] = "\n SHADER MEDIAN FILTER COMPATIBLE 24-32 bit IMAGE\n\n This shader cannot be used for real time display rendering as the performance \n of the algorithm is not satisfactory < 50 fps. \n The code would have to be changed and improved with C or assembler in order to\n be adapted for a real time application. \n\n In the state, this shader can be used for texture/surface transformation offline\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface. \n\n :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with \n or without per-pixel transparency / alpha channel)\n :param kernel_size_ : integer; Kernel size or neighbourhood pixels to be included default is 2\n Increase the effect with kernel size > 2 (effect overall speed is \n degrading quickly with large kernel size e.g > 2)\n :param fast_ : boolean; Flag for fast calculation (default True). Improve overall speed \n performance by using smaller texture sizes (see reduce_factor_ option)\n :param reduce_factor_: integer; Int value to reduce the size of the original surface to \n process. A value of 1, divide the original surface by 2 and a value of 2\n reduce the surface by 4 (value of 1 and 2 are acceptable, over 2 the \n image quality is too pixelated and blur) default value is 1 (div by 2).\n This argument as no effect if flag fast_=False\n :return: : void\n "; static PyObject *__pyx_pw_6shader_9median(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; unsigned short __pyx_v_kernel_size_; int __pyx_v_fast_; unsigned short __pyx_v_reduce_factor_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_kernel_size,&__pyx_n_s_fast,&__pyx_n_s_reduce_factor,0}; PyObject* values[4] = {0,0,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 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_surface)) != 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_kernel_size); 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_fast); 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_reduce_factor); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "median") < 0)) __PYX_ERR(1, 361, __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); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_surface_ = values[0]; if (values[1]) { __pyx_v_kernel_size_ = __Pyx_PyInt_As_unsigned_short(values[1]); if (unlikely((__pyx_v_kernel_size_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 363, __pyx_L3_error) } else { __pyx_v_kernel_size_ = ((unsigned short)2); } if (values[2]) { __pyx_v_fast_ = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_fast_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 364, __pyx_L3_error) } else { /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_8median(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, unsigned short __pyx_v_kernel_size_, int __pyx_v_fast_, unsigned short __pyx_v_reduce_factor_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 3; __pyx_t_1.kernel_size_ = __pyx_v_kernel_size_; __pyx_t_1.fast_ = __pyx_v_fast_; __pyx_t_1.reduce_factor_ = __pyx_v_reduce_factor_; __pyx_f_6shader_median(__pyx_v_surface_, 0, &__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 361, __pyx_L1_error) __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.median", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0362: object surface_,
0363: unsigned short int kernel_size_=2,
+0364: bint fast_=True,
int __pyx_v_fast_ = ((int)1); unsigned short __pyx_v_reduce_factor_ = ((unsigned short)1); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_fast_ = __pyx_optional_args->fast_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_reduce_factor_ = __pyx_optional_args->reduce_factor_; } } } } /* … */ __pyx_v_fast_ = ((int)1); } if (values[3]) { __pyx_v_reduce_factor_ = __Pyx_PyInt_As_unsigned_short(values[3]); if (unlikely((__pyx_v_reduce_factor_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 365, __pyx_L3_error) } else { __pyx_v_reduce_factor_ = ((unsigned short)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("median", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 361, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.median", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_8median(__pyx_self, __pyx_v_surface_, __pyx_v_kernel_size_, __pyx_v_fast_, __pyx_v_reduce_factor_);
0365: unsigned short int reduce_factor_=1
0366: ) except *:
0367: """
0368: SHADER MEDIAN FILTER COMPATIBLE 24-32 bit IMAGE
0369:
0370: This shader cannot be used for real time display rendering as the performance
0371: of the algorithm is not satisfactory < 50 fps.
0372: The code would have to be changed and improved with C or assembler in order to
0373: be adapted for a real time application.
0374:
0375: In the state, this shader can be used for texture/surface transformation offline
0376:
0377: * The changes are automatically applied inplace to the surface you do not need to create a
0378: new surface.
0379:
0380: :param surface_ : Pygame surface or display surface compatible (image 24-32 bit with
0381: or without per-pixel transparency / alpha channel)
0382: :param kernel_size_ : integer; Kernel size or neighbourhood pixels to be included default is 2
0383: Increase the effect with kernel size > 2 (effect overall speed is
0384: degrading quickly with large kernel size e.g > 2)
0385: :param fast_ : boolean; Flag for fast calculation (default True). Improve overall speed
0386: performance by using smaller texture sizes (see reduce_factor_ option)
0387: :param reduce_factor_: integer; Int value to reduce the size of the original surface to
0388: process. A value of 1, divide the original surface by 2 and a value of 2
0389: reduce the surface by 4 (value of 1 and 2 are acceptable, over 2 the
0390: image quality is too pixelated and blur) default value is 1 (div by 2).
0391: This argument as no effect if flag fast_=False
0392: :return: : void
0393: """
+0394: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 394, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0395: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 394, __pyx_L1_error) } } #endif
0396:
+0397: if kernel_size_ <= 0:
__pyx_t_3 = ((__pyx_v_kernel_size_ <= 0) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+0398: raise ValueError('\nArgument kernel_size_ cannot be <= 0')
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 398, __pyx_L1_error) /* … */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Argument_kernel_size__cannot_be); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_);
+0399: if not 0 < reduce_factor_ < 9:
__pyx_t_3 = (0 < __pyx_v_reduce_factor_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_reduce_factor_ < 9); } __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0); if (unlikely(__pyx_t_4)) { /* … */ }
+0400: raise ValueError('\nArgument reduce_factor_ must be in range [1 ... 8] ')
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 400, __pyx_L1_error) /* … */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Argument_reduce_factor__must_be); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 400, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2);
0401:
+0402: if fast_:
__pyx_t_4 = (__pyx_v_fast_ != 0); if (__pyx_t_4) { /* … */ goto __pyx_L5; }
+0403: median_fast(surface_, kernel_size_, reduce_factor_)
__pyx_t_5.__pyx_n = 2; __pyx_t_5.kernel_size_ = __pyx_v_kernel_size_; __pyx_t_5.reduce_factor_ = __pyx_v_reduce_factor_; __pyx_f_6shader_median_fast(__pyx_v_surface_, &__pyx_t_5);
0404: else:
+0405: shader_median_filter24_inplace_c(pixels3d(surface_), kernel_size_)
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 405, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8.__pyx_n = 1; __pyx_t_8.kernel_size_ = __pyx_v_kernel_size_; __pyx_f_6shader_shader_median_filter24_inplace_c(__pyx_t_7, &__pyx_t_8); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; } __pyx_L5:;
0406:
0407:
+0408: cpdef inline void median_grayscale(
static PyObject *__pyx_pw_6shader_11median_grayscale(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_median_grayscale(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_median_grayscale *__pyx_optional_args) { int __pyx_v_kernel_size_ = ((int)2); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_grayscale", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.median_grayscale", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_11median_grayscale(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_10median_grayscale[] = "\n SHADER MEDIAN FILTER (GRAYSCALE)\n\n This shader cannot be used for real time rendering as the performance of the algorithm are not\n satisfactory. The code would have to be changed and improved with C or assembler in order to\n be adapted for a real time application. \n\n In the state, this shader can be used for texture/surface transformation offline\n\n The surface is compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface. \n\n :param surface_: pygame.Surface; compatible 24 - 32 bit with or without alpha layer\n :param kernel_size_: integer; Kernel size (must be > 0), default value = 2\n :return: void \n "; static PyObject *__pyx_pw_6shader_11median_grayscale(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_kernel_size_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_grayscale (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_kernel_size,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kernel_size); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "median_grayscale") < 0)) __PYX_ERR(1, 408, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_kernel_size_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_kernel_size_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 410, __pyx_L3_error) } else { __pyx_v_kernel_size_ = ((int)2); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("median_grayscale", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 408, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.median_grayscale", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_10median_grayscale(__pyx_self, __pyx_v_surface_, __pyx_v_kernel_size_); 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_6shader_10median_grayscale(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_kernel_size_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_grayscale", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.kernel_size_ = __pyx_v_kernel_size_; __pyx_f_6shader_median_grayscale(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.median_grayscale", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0409: object surface_,
0410: int kernel_size_=2
0411: ):
0412: """
0413: SHADER MEDIAN FILTER (GRAYSCALE)
0414:
0415: This shader cannot be used for real time rendering as the performance of the algorithm are not
0416: satisfactory. The code would have to be changed and improved with C or assembler in order to
0417: be adapted for a real time application.
0418:
0419: In the state, this shader can be used for texture/surface transformation offline
0420:
0421: The surface is compatible 24 - 32 bit with or without alpha layer
0422:
0423: * The changes are automatically applied inplace to the surface you do not need to create a
0424: new surface.
0425:
0426: :param surface_: pygame.Surface; compatible 24 - 32 bit with or without alpha layer
0427: :param kernel_size_: integer; Kernel size (must be > 0), default value = 2
0428: :return: void
0429: """
+0430: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 430, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0431: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 430, __pyx_L1_error) } } #endif
0432:
+0433: assert kernel_size_ > 0, "\nArgument kernel_size_ cannot be <= 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_kernel_size_ > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_kernel_size__cannot_be); __PYX_ERR(1, 433, __pyx_L1_error) } } #endif
0434:
+0435: shader_median_grayscale_filter24_inplace_c(pixels3d(surface_), kernel_size_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 435, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 1; __pyx_t_6.kernel_size_ = __pyx_v_kernel_size_; __pyx_f_6shader_shader_median_grayscale_filter24_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0436:
0437:
+0438: cpdef inline void median_avg(
static PyObject *__pyx_pw_6shader_13median_avg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_median_avg(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_median_avg *__pyx_optional_args) { int __pyx_v_kernel_size_ = ((int)2); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_avg", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.median_avg", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_13median_avg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_12median_avg[] = "\n SHADER MEDIAN FILTER (AVERAGE)\n \n This shader cannot be used for real time rendering as the performance of the algorithm are not\n satisfactory. The code would have to be changed and improved with C or assembler in order to\n be adapted for a real time application. \n\n In the state, this shader can be used for texture/surface transformation offline\n\n The surface is compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface. \n\n :param surface_: pygame.Surface; compatible 24 - 32 bit with or without alpha layer\n :param kernel_size_: integer; Kernel size (must be > 0), default value = 2\n :return: void \n "; static PyObject *__pyx_pw_6shader_13median_avg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_kernel_size_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_avg (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_kernel_size,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_kernel_size); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "median_avg") < 0)) __PYX_ERR(1, 438, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_kernel_size_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_kernel_size_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 440, __pyx_L3_error) } else { __pyx_v_kernel_size_ = ((int)2); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("median_avg", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 438, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.median_avg", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_12median_avg(__pyx_self, __pyx_v_surface_, __pyx_v_kernel_size_); 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_6shader_12median_avg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_kernel_size_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("median_avg", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.kernel_size_ = __pyx_v_kernel_size_; __pyx_f_6shader_median_avg(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.median_avg", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0439: object surface_,
0440: int kernel_size_=2
0441: ):
0442: """
0443: SHADER MEDIAN FILTER (AVERAGE)
0444:
0445: This shader cannot be used for real time rendering as the performance of the algorithm are not
0446: satisfactory. The code would have to be changed and improved with C or assembler in order to
0447: be adapted for a real time application.
0448:
0449: In the state, this shader can be used for texture/surface transformation offline
0450:
0451: The surface is compatible 24 - 32 bit with or without alpha layer
0452:
0453: * The changes are automatically applied inplace to the surface you do not need to create a
0454: new surface.
0455:
0456: :param surface_: pygame.Surface; compatible 24 - 32 bit with or without alpha layer
0457: :param kernel_size_: integer; Kernel size (must be > 0), default value = 2
0458: :return: void
0459: """
0460:
+0461: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 461, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0462: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 461, __pyx_L1_error) } } #endif
0463:
+0464: assert kernel_size_ > 0, "\nArgument kernel_size_ cannot be <= 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_kernel_size_ > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_kernel_size__cannot_be); __PYX_ERR(1, 464, __pyx_L1_error) } } #endif
0465:
+0466: shader_median_filter24_avg_inplace_c(pixels3d(surface_), kernel_size_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 1; __pyx_t_6.kernel_size_ = __pyx_v_kernel_size_; __pyx_f_6shader_shader_median_filter24_avg_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0467:
0468:
0469:
+0470: cpdef inline void color_reduction(
static PyObject *__pyx_pw_6shader_15color_reduction(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_color_reduction(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_color_reduction *__pyx_optional_args) { int __pyx_v_color_ = ((int)8); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("color_reduction", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_color_ = __pyx_optional_args->color_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.color_reduction", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_15color_reduction(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_14color_reduction[] = "\n COLOR REDUCTION SHADER\n\n Decrease the amount of colors in the display or texture.\n The method of color reduction is very simple: every color of the original picture is replaced\n by an appropriate color from the limited palette that is accessible.\n \n The surface is compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface you do not need to create a \n new surface. \n \n e.g:\n color_reduction(surface, 8)\n\n :param surface_: pygame.Surface; compatible 24 - 32 bit \n :param color_: integer must be > 0 default 8\n :return: void \n "; static PyObject *__pyx_pw_6shader_15color_reduction(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_color_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("color_reduction (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_color,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_color); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "color_reduction") < 0)) __PYX_ERR(1, 470, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_color_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_color_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 472, __pyx_L3_error) } else { __pyx_v_color_ = ((int)8); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("color_reduction", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 470, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.color_reduction", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_14color_reduction(__pyx_self, __pyx_v_surface_, __pyx_v_color_); 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_6shader_14color_reduction(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_color_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("color_reduction", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.color_ = __pyx_v_color_; __pyx_f_6shader_color_reduction(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.color_reduction", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0471: object surface_,
0472: int color_=8
0473: ):
0474: """
0475: COLOR REDUCTION SHADER
0476:
0477: Decrease the amount of colors in the display or texture.
0478: The method of color reduction is very simple: every color of the original picture is replaced
0479: by an appropriate color from the limited palette that is accessible.
0480:
0481: The surface is compatible 24 - 32 bit with or without alpha layer
0482:
0483: * The changes are automatically applied inplace to the surface you do not need to create a
0484: new surface.
0485:
0486: e.g:
0487: color_reduction(surface, 8)
0488:
0489: :param surface_: pygame.Surface; compatible 24 - 32 bit
0490: :param color_: integer must be > 0 default 8
0491: :return: void
0492: """
+0493: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 493, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 493, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0494: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 494, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 493, __pyx_L1_error) } } #endif
0495:
+0496: assert color_ > 0, "Argument color_number must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_color_ > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_color_number_must_be_0); __PYX_ERR(1, 496, __pyx_L1_error) } } #endif
0497:
+0498: shader_color_reduction24_inplace_c(pixels3d(surface_), color_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 498, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 498, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_color_reduction24_inplace_c(__pyx_t_5, __pyx_v_color_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0499:
0500:
+0501: cpdef inline void sobel(
static PyObject *__pyx_pw_6shader_17sobel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_sobel(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_sobel *__pyx_optional_args) { int __pyx_v_threshold_ = ((int)64); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sobel", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold_ = __pyx_optional_args->threshold_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.sobel", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_17sobel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_16sobel[] = "\n SHADER SOBEL (EDGE DETECTION)\n\n Transform the game display or a pygame surface into a sobel equivalent model\n (surface edge detection)\n\n The surface is compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n\n e.g:\n sobel(surface, 64)\n\n :param surface_: pygame.Surface; compatible 24 - 32 bit \n :param threshold_: integer; Value for detecting the edges default 64\n :return:\n "; static PyObject *__pyx_pw_6shader_17sobel(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_threshold_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sobel (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_threshold,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_threshold); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sobel") < 0)) __PYX_ERR(1, 501, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_threshold_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_threshold_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 503, __pyx_L3_error) } else { __pyx_v_threshold_ = ((int)64); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sobel", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 501, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.sobel", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_16sobel(__pyx_self, __pyx_v_surface_, __pyx_v_threshold_); 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_6shader_16sobel(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_threshold_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sobel", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.threshold_ = __pyx_v_threshold_; __pyx_f_6shader_sobel(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.sobel", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0502: object surface_,
0503: int threshold_ = 64
0504: ):
0505: """
0506: SHADER SOBEL (EDGE DETECTION)
0507:
0508: Transform the game display or a pygame surface into a sobel equivalent model
0509: (surface edge detection)
0510:
0511: The surface is compatible 24 - 32 bit with or without alpha layer
0512:
0513: * The changes are automatically applied inplace to the surface, you do not need to create a
0514: new surface.
0515:
0516: e.g:
0517: sobel(surface, 64)
0518:
0519: :param surface_: pygame.Surface; compatible 24 - 32 bit
0520: :param threshold_: integer; Value for detecting the edges default 64
0521: :return:
0522: """
+0523: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 523, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0524: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 523, __pyx_L1_error) } } #endif
0525:
+0526: assert -1 < threshold_ < 256, "\nArgument threshold must be an integer in range [0 ... 255]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1L < __pyx_v_threshold_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_threshold_ < 0x100); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_threshold_must_be_an_i); __PYX_ERR(1, 526, __pyx_L1_error) } } #endif
0527:
+0528: shader_sobel24_inplace_c(pixels3d(surface_), threshold_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 528, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 1; __pyx_t_6.threshold = __pyx_v_threshold_; __pyx_f_6shader_shader_sobel24_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0529:
0530:
+0531: cpdef inline void sobel_fast(
static PyObject *__pyx_pw_6shader_19sobel_fast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_sobel_fast(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_sobel_fast *__pyx_optional_args) { int __pyx_v_threshold_ = ((int)64); unsigned short __pyx_v_factor_ = ((unsigned short)1); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sobel_fast", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold_ = __pyx_optional_args->threshold_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_factor_ = __pyx_optional_args->factor_; } } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.sobel_fast", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_19sobel_fast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_18sobel_fast[] = "\n SHADER FAST SOBEL (EDGE DETECTION)\n\n Transform the game display or a pygame surface into a sobel equivalent model\n (surface edge detection).This version is slightly fastest than shader_sobel24_inplace_c as\n it down-scale the array containing all the pixels and apply the sobel algorithm to a smaller\n sample. When the processing is done, the array is re-scale to its original dimensions.\n If this method is in theory faster than shader_sobel24_inplace_c, down-scaling and up-scaling\n an array does have a side effect of decreasing the overall image definition\n (jagged lines non-antialiasing)\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n \n e.g:\n sobel_fast(surface, 64, factor_=1)\n\n :param surface_: pygame.surface compatible 24-32 bit \n :param threshold_: integer; default value is 24 \n :param factor_: integer; default value is 1 (div by 2)\n :return:\n "; static PyObject *__pyx_pw_6shader_19sobel_fast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_threshold_; unsigned short __pyx_v_factor_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sobel_fast (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_threshold,&__pyx_n_s_factor,0}; PyObject* values[3] = {0,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 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_surface)) != 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_threshold); 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_factor); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sobel_fast") < 0)) __PYX_ERR(1, 531, __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_surface_ = values[0]; if (values[1]) { __pyx_v_threshold_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_threshold_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 533, __pyx_L3_error) } else { __pyx_v_threshold_ = ((int)64); } if (values[2]) { __pyx_v_factor_ = __Pyx_PyInt_As_unsigned_short(values[2]); if (unlikely((__pyx_v_factor_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 534, __pyx_L3_error) } else { __pyx_v_factor_ = ((unsigned short)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sobel_fast", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 531, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.sobel_fast", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_18sobel_fast(__pyx_self, __pyx_v_surface_, __pyx_v_threshold_, __pyx_v_factor_); 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_6shader_18sobel_fast(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_threshold_, unsigned short __pyx_v_factor_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sobel_fast", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 2; __pyx_t_1.threshold_ = __pyx_v_threshold_; __pyx_t_1.factor_ = __pyx_v_factor_; __pyx_f_6shader_sobel_fast(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.sobel_fast", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0532: object surface_,
0533: int threshold_ = 64,
0534: unsigned short factor_ = 1
0535: ):
0536: """
0537: SHADER FAST SOBEL (EDGE DETECTION)
0538:
0539: Transform the game display or a pygame surface into a sobel equivalent model
0540: (surface edge detection).This version is slightly fastest than shader_sobel24_inplace_c as
0541: it down-scale the array containing all the pixels and apply the sobel algorithm to a smaller
0542: sample. When the processing is done, the array is re-scale to its original dimensions.
0543: If this method is in theory faster than shader_sobel24_inplace_c, down-scaling and up-scaling
0544: an array does have a side effect of decreasing the overall image definition
0545: (jagged lines non-antialiasing)
0546:
0547: Compatible 24 - 32 bit with or without alpha layer
0548:
0549: * The changes are automatically applied inplace to the surface, you do not need to create a
0550: new surface.
0551:
0552: e.g:
0553: sobel_fast(surface, 64, factor_=1)
0554:
0555: :param surface_: pygame.surface compatible 24-32 bit
0556: :param threshold_: integer; default value is 24
0557: :param factor_: integer; default value is 1 (div by 2)
0558: :return:
0559: """
+0560: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 560, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0561: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 560, __pyx_L1_error) } } #endif
0562:
+0563: assert -1 < threshold_ < 256, "\nArgument threshold must be an integer in range [0 ... 255]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1L < __pyx_v_threshold_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_threshold_ < 0x100); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_threshold_must_be_an_i); __PYX_ERR(1, 563, __pyx_L1_error) } } #endif
+0564: assert 0 < factor_ < 9, "\nArgument factor_ must be in range [1 ... 8]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (0 < __pyx_v_factor_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_factor_ < 9); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_factor__must_be_in_ran); __PYX_ERR(1, 564, __pyx_L1_error) } } #endif
0565:
+0566: shader_sobel24_fast_inplace_c(surface_, threshold_, factor_)
__pyx_t_4.__pyx_n = 2; __pyx_t_4.threshold_ = __pyx_v_threshold_; __pyx_t_4.factor_ = __pyx_v_factor_; __pyx_f_6shader_shader_sobel24_fast_inplace_c(__pyx_v_surface_, &__pyx_t_4);
0567:
0568:
0569:
0570:
+0571: cpdef inline void invert(object surface_):
static PyObject *__pyx_pw_6shader_21invert(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_invert(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("invert", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.invert", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_21invert(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_20invert[] = "\n SHADER INVERT PIXELS\n \n Invert all pixels of the display or a given texture\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n \n e.g:\n invert(surface)\n \n :param surface_: pygame.surface; compatible 24 - 32 bit surfaces\n :return: void\n "; static PyObject *__pyx_pw_6shader_21invert(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("invert (wrapper)", 0); __pyx_r = __pyx_pf_6shader_20invert(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_20invert(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("invert", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_invert(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 571, __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("shader.invert", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0572: """
0573: SHADER INVERT PIXELS
0574:
0575: Invert all pixels of the display or a given texture
0576:
0577: Compatible 24 - 32 bit with or without alpha layer
0578:
0579: * The changes are automatically applied inplace to the surface, you do not need to create a
0580: new surface.
0581:
0582: e.g:
0583: invert(surface)
0584:
0585: :param surface_: pygame.surface; compatible 24 - 32 bit surfaces
0586: :return: void
0587: """
+0588: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 588, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0589: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 588, __pyx_L1_error) } } #endif
0590:
+0591: shader_invert_surface_24bit_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 591, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_invert_surface_24bit_inplace_c(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0592:
0593:
0594:
+0595: cpdef inline void hsl_effect(object surface_, float shift_):
static PyObject *__pyx_pw_6shader_23hsl_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_hsl_effect(PyObject *__pyx_v_surface_, float __pyx_v_shift_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_effect", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.hsl_effect", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_23hsl_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_22hsl_effect[] = "\n ROTATE THE HUE OF THE GAME DISPLAY OR GIVEN TEXTURE\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n \n e.g:\n hsl_effect(surface, 0.2)\n \n :param surface_: pygame.Surface; Compatible 24 - 32 bit surfaces\n :param shift_: float; float value in range [-1.0 ... 1.0]\n :return: void \n "; static PyObject *__pyx_pw_6shader_23hsl_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_effect (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("hsl_effect", 1, 2, 2, 1); __PYX_ERR(1, 595, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hsl_effect") < 0)) __PYX_ERR(1, 595, __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_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 595, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("hsl_effect", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 595, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.hsl_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_22hsl_effect(__pyx_self, __pyx_v_surface_, __pyx_v_shift_); 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_6shader_22hsl_effect(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_effect", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_hsl_effect(__pyx_v_surface_, __pyx_v_shift_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 595, __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("shader.hsl_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0596: """
0597: ROTATE THE HUE OF THE GAME DISPLAY OR GIVEN TEXTURE
0598:
0599: Compatible 24 - 32 bit with or without alpha layer
0600:
0601: * The changes are automatically applied inplace to the surface, you do not need to create a
0602: new surface.
0603:
0604: e.g:
0605: hsl_effect(surface, 0.2)
0606:
0607: :param surface_: pygame.Surface; Compatible 24 - 32 bit surfaces
0608: :param shift_: float; float value in range [-1.0 ... 1.0]
0609: :return: void
0610: """
+0611: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 611, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0612: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 611, __pyx_L1_error) } } #endif
0613:
+0614: assert -1.0 <= shift_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift_must_be_in_range); __PYX_ERR(1, 614, __pyx_L1_error) } } #endif
0615: "Argument shift must be in range[-1.0 ... 1.0]"
0616:
+0617: shader_hsl_surface24bit_inplace_c(pixels3d(surface_), shift_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 617, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_hsl_surface24bit_inplace_c(__pyx_t_5, __pyx_v_shift_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0618:
0619:
0620: # todo wiki
+0621: cpdef inline void hsl_fast(
static PyObject *__pyx_pw_6shader_25hsl_fast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_hsl_fast(PyObject *__pyx_v_surface_, float __pyx_v_shift_, __Pyx_memviewslice __pyx_v_hsl_model_, __Pyx_memviewslice __pyx_v_rgb_model_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_fast", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.hsl_fast", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_25hsl_fast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_24hsl_fast[] = " \n ROTATE THE HUE OF AN IMAGE USING STORED HSL TO RGB AND RGB TO HSL VALUES\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n\n e.g:\n rgb2hsl_model = hsl_to_rgb_model()\n hsl2rgb_model = rgb_to_hsl_model()\n hsl_fast(\n image,\n 0.1,\n hsl_model_=hsl2rgb_model,\n rgb_model_=rgb2hsl_model)\n\n :param surface_: pygame.Surface; compatible 24 - 32 bit surfaces\n :param shift_: float; value must be in range [ -1.0 ... + 1.0]\n :param hsl_model_: 3d numpy.ndarray shape (256, 256, 256, 3) see hsl_to_rgb_model function \n :param rgb_model_: 3d numpy.ndarray shape (256, 256, 256, 3) see rgb_to_hsl_model function\n :return:\n "; static PyObject *__pyx_pw_6shader_25hsl_fast(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; __Pyx_memviewslice __pyx_v_hsl_model_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_rgb_model_ = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_fast (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,&__pyx_n_s_hsl_model,&__pyx_n_s_rgb_model,0}; PyObject* values[4] = {0,0,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 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_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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("hsl_fast", 1, 4, 4, 1); __PYX_ERR(1, 621, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hsl_model)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("hsl_fast", 1, 4, 4, 2); __PYX_ERR(1, 621, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rgb_model)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("hsl_fast", 1, 4, 4, 3); __PYX_ERR(1, 621, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "hsl_fast") < 0)) __PYX_ERR(1, 621, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_surface_ = values[0]; __pyx_v_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 623, __pyx_L3_error) __pyx_v_hsl_model_ = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_hsl_model_.memview)) __PYX_ERR(1, 624, __pyx_L3_error) __pyx_v_rgb_model_ = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_unsigned_char(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_rgb_model_.memview)) __PYX_ERR(1, 625, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("hsl_fast", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 621, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.hsl_fast", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_24hsl_fast(__pyx_self, __pyx_v_surface_, __pyx_v_shift_, __pyx_v_hsl_model_, __pyx_v_rgb_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_6shader_24hsl_fast(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_, __Pyx_memviewslice __pyx_v_hsl_model_, __Pyx_memviewslice __pyx_v_rgb_model_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_fast", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_hsl_model_.memview)) { __Pyx_RaiseUnboundLocalError("hsl_model_"); __PYX_ERR(1, 621, __pyx_L1_error) } if (unlikely(!__pyx_v_rgb_model_.memview)) { __Pyx_RaiseUnboundLocalError("rgb_model_"); __PYX_ERR(1, 621, __pyx_L1_error) } __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_hsl_fast(__pyx_v_surface_, __pyx_v_shift_, __pyx_v_hsl_model_, __pyx_v_rgb_model_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 621, __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("shader.hsl_fast", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_hsl_model_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_model_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0622: object surface_,
0623: float shift_,
0624: float [:, :, :, ::1] hsl_model_,
0625: unsigned char [:, :, :, ::1] rgb_model_
0626: ):
0627: """
0628: ROTATE THE HUE OF AN IMAGE USING STORED HSL TO RGB AND RGB TO HSL VALUES
0629:
0630: Compatible 24 - 32 bit with or without alpha layer
0631:
0632: * The changes are automatically applied inplace to the surface, you do not need to create a
0633: new surface.
0634:
0635: e.g:
0636: rgb2hsl_model = hsl_to_rgb_model()
0637: hsl2rgb_model = rgb_to_hsl_model()
0638: hsl_fast(
0639: image,
0640: 0.1,
0641: hsl_model_=hsl2rgb_model,
0642: rgb_model_=rgb2hsl_model)
0643:
0644: :param surface_: pygame.Surface; compatible 24 - 32 bit surfaces
0645: :param shift_: float; value must be in range [ -1.0 ... + 1.0]
0646: :param hsl_model_: 3d numpy.ndarray shape (256, 256, 256, 3) see hsl_to_rgb_model function
0647: :param rgb_model_: 3d numpy.ndarray shape (256, 256, 256, 3) see rgb_to_hsl_model function
0648: :return:
0649: """
+0650: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 650, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0651: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 650, __pyx_L1_error) } } #endif
+0652: assert -1.0 <= shift_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift_must_be_in_range); __PYX_ERR(1, 652, __pyx_L1_error) } } #endif
0653: "Argument shift must be in range[-1.0 ... 1.0]"
+0654: assert PyObject_IsInstance(hsl_model_, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_hsl_model_, 4, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 654, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0655: "\nArgument hsl_model_ must be a numpy.ndarray or memoryview type, got %s " % type(
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_hsl_model__must_be_a_n, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 654, __pyx_L1_error) } } #endif
+0656: hsl_model_)
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_hsl_model_, 4, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+0657: assert PyObject_IsInstance(rgb_model_, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_rgb_model_, 4, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 657, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0658: "\nArgument rgb_model_ must be a numpy.ndarray or memoryview type, got %s " % type(
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_rgb_model__must_be_a_n, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 657, __pyx_L1_error) } } #endif
+0659: rgb_model_)
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_rgb_model_, 4, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
0660:
+0661: shader_hsl_surface24bit_fast_inplace_c(pixels3d(surface_), shift_, hsl_model_, rgb_model_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 661, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_hsl_surface24bit_fast_inplace_c(__pyx_t_5, __pyx_v_shift_, __pyx_v_hsl_model_, __pyx_v_rgb_model_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0662:
0663:
+0664: cpdef inline void blur(object surface_, t_=1):
static PyObject *__pyx_pw_6shader_27blur(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_blur(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_blur *__pyx_optional_args) { PyObject *__pyx_v_t_ = ((PyObject *)__pyx_int_1); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_t_ = __pyx_optional_args->t_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.blur", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_27blur(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_26blur[] = "\n APPLY A GAUSSIAN BLUR EFFECT TO THE GAME DISPLAY OR TO A GIVEN TEXTURE (KERNEL 5x5)\n\n # Gaussian kernel 5x5\n # |1 4 6 4 1|\n # |4 16 24 16 4|\n # |6 24 36 24 6| x 1/256\n # |4 16 24 16 4|\n # |1 4 6 4 1|\n This method is using convolution property and process the image in two passes,\n first the horizontal convolution and last the vertical convolution\n pixels convoluted outside image edges will be set to adjacent edge value\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n\n :param surface_: pygame.Surface; compatible 24 - 32 bit surfaces\n :param t_ : integer; number if times must be >0\n :return: void \n "; static PyObject *__pyx_pw_6shader_27blur(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; PyObject *__pyx_v_t_ = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_t,0}; PyObject* values[2] = {0,0}; values[1] = ((PyObject *)__pyx_int_1); 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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blur") < 0)) __PYX_ERR(1, 664, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; __pyx_v_t_ = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("blur", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 664, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.blur", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_26blur(__pyx_self, __pyx_v_surface_, __pyx_v_t_); 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_6shader_26blur(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, PyObject *__pyx_v_t_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blur", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.t_ = __pyx_v_t_; __pyx_f_6shader_blur(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.blur", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0665: """
0666: APPLY A GAUSSIAN BLUR EFFECT TO THE GAME DISPLAY OR TO A GIVEN TEXTURE (KERNEL 5x5)
0667:
0668: # Gaussian kernel 5x5
0669: # |1 4 6 4 1|
0670: # |4 16 24 16 4|
0671: # |6 24 36 24 6| x 1/256
0672: # |4 16 24 16 4|
0673: # |1 4 6 4 1|
0674: This method is using convolution property and process the image in two passes,
0675: first the horizontal convolution and last the vertical convolution
0676: pixels convoluted outside image edges will be set to adjacent edge value
0677:
0678: Compatible 24 - 32 bit with or without alpha layer
0679:
0680: * The changes are automatically applied inplace to the surface, you do not need to create a
0681: new surface.
0682:
0683: :param surface_: pygame.Surface; compatible 24 - 32 bit surfaces
0684: :param t_ : integer; number if times must be >0
0685: :return: void
0686: """
+0687: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 687, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0688: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 687, __pyx_L1_error) } } #endif
+0689: assert t_ > 0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = PyObject_RichCompare(__pyx_v_t_, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 689, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(1, 689, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) {
+0690: "\nArgument t_ must be > 0, got %s " % t_
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_t__must_be_0_got_s, __pyx_v_t_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 689, __pyx_L1_error) } } #endif
0691:
+0692: shader_blur5x5_array24_inplace_c(pixels3d(surface_), None, t_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 692, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 2; __pyx_t_6.mask = Py_None; __pyx_t_6.t = __pyx_v_t_; __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0693:
0694:
+0695: cpdef inline void wave(object surface_, float rad, int size):
static PyObject *__pyx_pw_6shader_29wave(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_wave(PyObject *__pyx_v_surface_, float __pyx_v_rad, int __pyx_v_size, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wave", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.wave", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_29wave(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_28wave[] = "\n CREATE A WAVE EFFECT TO THE GAME DISPLAY OR TO A GIVEN SURFACE\n\n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n\n e.g:\n wave(surface, 8 * math.pi/180.0 + frame_number, 5)\n \n :param surface_: pygame.Surface; pygame surface compatible 24 - 32 bit \n :param rad : float; angle in rad to rotate over time\n :param size : int; Number of sub-surfaces\n :return : void\n "; static PyObject *__pyx_pw_6shader_29wave(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_rad; int __pyx_v_size; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wave (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_rad,&__pyx_n_s_size,0}; PyObject* values[3] = {0,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 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_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_rad)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("wave", 1, 3, 3, 1); __PYX_ERR(1, 695, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("wave", 1, 3, 3, 2); __PYX_ERR(1, 695, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "wave") < 0)) __PYX_ERR(1, 695, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_surface_ = values[0]; __pyx_v_rad = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_rad == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 695, __pyx_L3_error) __pyx_v_size = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 695, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("wave", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 695, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.wave", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_28wave(__pyx_self, __pyx_v_surface_, __pyx_v_rad, __pyx_v_size); 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_6shader_28wave(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_rad, int __pyx_v_size) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wave", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_wave(__pyx_v_surface_, __pyx_v_rad, __pyx_v_size, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 695, __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("shader.wave", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0696: """
0697: CREATE A WAVE EFFECT TO THE GAME DISPLAY OR TO A GIVEN SURFACE
0698:
0699: Compatible 24 - 32 bit with or without alpha layer
0700:
0701: * The changes are automatically applied inplace to the surface, you do not need to create a
0702: new surface.
0703:
0704: e.g:
0705: wave(surface, 8 * math.pi/180.0 + frame_number, 5)
0706:
0707: :param surface_: pygame.Surface; pygame surface compatible 24 - 32 bit
0708: :param rad : float; angle in rad to rotate over time
0709: :param size : int; Number of sub-surfaces
0710: :return : void
0711: """
+0712: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 712, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0713: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 712, __pyx_L1_error) } } #endif
+0714: assert size > 0, "Argument size must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_size > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_size_must_be_0); __PYX_ERR(1, 714, __pyx_L1_error) } } #endif
0715:
+0716: shader_wave24bit_inplace_c(pixels3d(surface_), rad, size)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 716, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 716, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_wave24bit_inplace_c(__pyx_t_5, __pyx_v_rad, __pyx_v_size); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0717:
0718:
+0719: cpdef inline void swirl(object surface_, float degrees):
static PyObject *__pyx_pw_6shader_31swirl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_swirl(PyObject *__pyx_v_surface_, float __pyx_v_degrees, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("swirl", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.swirl", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_31swirl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_30swirl[] = "\n SWIRL AN IMAGE (ANGLE APPROXIMATION METHOD)\n\n This algorithm uses a table of cos and sin.\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n\n e.g:\n swirl(surface, 1.0)\n \n :param surface_: pygame.Surface, compatible 24 - 32 bit \n :param degrees : float; angle in degrees \n :return : void \n "; static PyObject *__pyx_pw_6shader_31swirl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_degrees; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("swirl (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_degrees,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_degrees)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("swirl", 1, 2, 2, 1); __PYX_ERR(1, 719, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "swirl") < 0)) __PYX_ERR(1, 719, __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_degrees = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_degrees == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 719, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("swirl", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 719, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.swirl", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_30swirl(__pyx_self, __pyx_v_surface_, __pyx_v_degrees); 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_6shader_30swirl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_degrees) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("swirl", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_swirl(__pyx_v_surface_, __pyx_v_degrees, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 719, __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("shader.swirl", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0720: """
0721: SWIRL AN IMAGE (ANGLE APPROXIMATION METHOD)
0722:
0723: This algorithm uses a table of cos and sin.
0724:
0725: Compatible 24 - 32 bit with or without alpha layer
0726:
0727: * The changes are automatically applied inplace to the surface, you do not need to create a
0728: new surface.
0729:
0730: e.g:
0731: swirl(surface, 1.0)
0732:
0733: :param surface_: pygame.Surface, compatible 24 - 32 bit
0734: :param degrees : float; angle in degrees
0735: :return : void
0736: """
+0737: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 737, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0738: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 737, __pyx_L1_error) } } #endif
0739:
+0740: shader_swirl24bit_inplace_c(pixels3d(surface_), degrees)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 740, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 740, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 740, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_swirl24bit_inplace_c(__pyx_t_5, __pyx_v_degrees); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0741:
0742:
0743:
+0744: cpdef inline void swirl2(object surface_, float degrees):
static PyObject *__pyx_pw_6shader_33swirl2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_swirl2(PyObject *__pyx_v_surface_, float __pyx_v_degrees, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("swirl2", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.swirl2", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_33swirl2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_32swirl2[] = "\n SWIRL AN IMAGE WITHOUT ANGLE APPROXIMATION\n\n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n \n e.g:\n swirl(surface_, frame_number)\n \n :param surface_: pygame.Surface, compatible 24 - 32 bit \n :param degrees : float; angle in degrees\n :return : void \n "; static PyObject *__pyx_pw_6shader_33swirl2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_degrees; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("swirl2 (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_degrees,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_degrees)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("swirl2", 1, 2, 2, 1); __PYX_ERR(1, 744, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "swirl2") < 0)) __PYX_ERR(1, 744, __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_degrees = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_degrees == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 744, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("swirl2", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 744, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.swirl2", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_32swirl2(__pyx_self, __pyx_v_surface_, __pyx_v_degrees); 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_6shader_32swirl2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_degrees) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("swirl2", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_swirl2(__pyx_v_surface_, __pyx_v_degrees, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 744, __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("shader.swirl2", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0745: """
0746: SWIRL AN IMAGE WITHOUT ANGLE APPROXIMATION
0747:
0748: Compatible 24 - 32 bit with or without alpha layer
0749:
0750: * The changes are automatically applied inplace to the surface, you do not need to create a
0751: new surface.
0752:
0753: e.g:
0754: swirl(surface_, frame_number)
0755:
0756: :param surface_: pygame.Surface, compatible 24 - 32 bit
0757: :param degrees : float; angle in degrees
0758: :return : void
0759: """
+0760: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 760, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0761: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 760, __pyx_L1_error) } } #endif
0762:
+0763: shader_swirl24bit_inplace_c1(pixels3d(surface_), degrees)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 763, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_swirl24bit_inplace_c1(__pyx_t_5, __pyx_v_degrees); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0764:
0765:
0766:
+0767: cpdef inline void plasma_config(
static PyObject *__pyx_pw_6shader_35plasma_config(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_plasma_config(PyObject *__pyx_v_surface_, int __pyx_v_frame, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_plasma_config *__pyx_optional_args) { float __pyx_v_hue_ = __pyx_k__3; float __pyx_v_sat_ = __pyx_k__4; float __pyx_v_value_ = __pyx_k__5; float __pyx_v_a_ = __pyx_k__6; float __pyx_v_b_ = __pyx_k__7; float __pyx_v_c_ = __pyx_k__8; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plasma_config", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_hue_ = __pyx_optional_args->hue_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_sat_ = __pyx_optional_args->sat_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_value_ = __pyx_optional_args->value_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_a_ = __pyx_optional_args->a_; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_b_ = __pyx_optional_args->b_; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_c_ = __pyx_optional_args->c_; } } } } } } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.plasma_config", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_35plasma_config(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_34plasma_config[] = "\n\n CREATE A BASIC PLASMA EFFECT ON THE TOP OF A PYGAME SURFACE\n\n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n\n e.g:\n plasma_config(surface, frame_number)\n\n :param a_ : float; default value 1.0/255.0 control the plasma equation\n :param b_ : float; default value 1.0/12.0 control the plasma equation\n :param c_ : float; default value 1.0/12.0 control the plasma equation\n :param value_ : float; default value 1.0/8.0 value factor\n :param sat_ : float; default value 1.0/6.0 saturation value\n :param hue_ : float; default value 1.0/6.0 hue value factor\n :param surface_ : pygame.surface; compatible 24 - 32 bit\n :param frame : integer; Variable that need to change over time\n :return : void\n "; static PyObject *__pyx_pw_6shader_35plasma_config(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_frame; float __pyx_v_hue_; float __pyx_v_sat_; float __pyx_v_value_; float __pyx_v_a_; float __pyx_v_b_; float __pyx_v_c_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plasma_config (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_frame,&__pyx_n_s_hue,&__pyx_n_s_sat,&__pyx_n_s_value,&__pyx_n_s_a,&__pyx_n_s_b,&__pyx_n_s_c,0}; PyObject* values[8] = {0,0,0,0,0,0,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 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_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_frame)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("plasma_config", 0, 2, 8, 1); __PYX_ERR(1, 767, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hue); 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_sat); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_value); if (value) { values[4] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_a); if (value) { values[5] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_b); if (value) { values[6] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_c); if (value) { values[7] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "plasma_config") < 0)) __PYX_ERR(1, 767, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_surface_ = values[0]; __pyx_v_frame = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_frame == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 769, __pyx_L3_error) if (values[2]) { __pyx_v_hue_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_hue_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 770, __pyx_L3_error) } else { __pyx_v_hue_ = __pyx_k__3; } if (values[3]) { __pyx_v_sat_ = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_sat_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 771, __pyx_L3_error) } else { __pyx_v_sat_ = __pyx_k__4; } if (values[4]) { __pyx_v_value_ = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_value_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 772, __pyx_L3_error) } else { __pyx_v_value_ = __pyx_k__5; } if (values[5]) { __pyx_v_a_ = __pyx_PyFloat_AsFloat(values[5]); if (unlikely((__pyx_v_a_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 773, __pyx_L3_error) } else { __pyx_v_a_ = __pyx_k__6; } if (values[6]) { __pyx_v_b_ = __pyx_PyFloat_AsFloat(values[6]); if (unlikely((__pyx_v_b_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 774, __pyx_L3_error) } else { __pyx_v_b_ = __pyx_k__7; } if (values[7]) { __pyx_v_c_ = __pyx_PyFloat_AsFloat(values[7]); if (unlikely((__pyx_v_c_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 775, __pyx_L3_error) } else { __pyx_v_c_ = __pyx_k__8; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("plasma_config", 0, 2, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 767, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.plasma_config", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_34plasma_config(__pyx_self, __pyx_v_surface_, __pyx_v_frame, __pyx_v_hue_, __pyx_v_sat_, __pyx_v_value_, __pyx_v_a_, __pyx_v_b_, __pyx_v_c_); 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_6shader_34plasma_config(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_frame, float __pyx_v_hue_, float __pyx_v_sat_, float __pyx_v_value_, float __pyx_v_a_, float __pyx_v_b_, float __pyx_v_c_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plasma_config", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 6; __pyx_t_1.hue_ = __pyx_v_hue_; __pyx_t_1.sat_ = __pyx_v_sat_; __pyx_t_1.value_ = __pyx_v_value_; __pyx_t_1.a_ = __pyx_v_a_; __pyx_t_1.b_ = __pyx_v_b_; __pyx_t_1.c_ = __pyx_v_c_; __pyx_f_6shader_plasma_config(__pyx_v_surface_, __pyx_v_frame, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.plasma_config", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0768: object surface_,
0769: int frame,
+0770: float hue_=1.0/6.0,
__pyx_k__3 = (1.0 / 6.0); /* … */ __pyx_k__3 = (1.0 / 6.0);
+0771: float sat_=1.0/6.0,
__pyx_k__4 = (1.0 / 6.0); /* … */ __pyx_k__4 = (1.0 / 6.0);
+0772: float value_=1.0/8.0,
__pyx_k__5 = (1.0 / 8.0); /* … */ __pyx_k__5 = (1.0 / 8.0);
+0773: float a_=1.0/255.0,
__pyx_k__6 = (1.0 / 255.0); /* … */ __pyx_k__6 = (1.0 / 255.0);
+0774: float b_=1.0/12.0,
__pyx_k__7 = (1.0 / 12.0); /* … */ __pyx_k__7 = (1.0 / 12.0);
+0775: float c_=1.0/12.0
__pyx_k__8 = (1.0 / 12.0); /* … */ __pyx_k__8 = (1.0 / 12.0);
0776: ):
0777: """
0778:
0779: CREATE A BASIC PLASMA EFFECT ON THE TOP OF A PYGAME SURFACE
0780:
0781: Compatible 24 - 32 bit with or without alpha layer
0782:
0783: * The changes are automatically applied inplace to the surface, you do not need to create a
0784: new surface.
0785:
0786: e.g:
0787: plasma_config(surface, frame_number)
0788:
0789: :param a_ : float; default value 1.0/255.0 control the plasma equation
0790: :param b_ : float; default value 1.0/12.0 control the plasma equation
0791: :param c_ : float; default value 1.0/12.0 control the plasma equation
0792: :param value_ : float; default value 1.0/8.0 value factor
0793: :param sat_ : float; default value 1.0/6.0 saturation value
0794: :param hue_ : float; default value 1.0/6.0 hue value factor
0795: :param surface_ : pygame.surface; compatible 24 - 32 bit
0796: :param frame : integer; Variable that need to change over time
0797: :return : void
0798: """
+0799: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 799, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0800: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 799, __pyx_L1_error) } } #endif
0801:
+0802: shader_plasma24bit_inplace_c(pixels3d(surface_), frame, hue_, sat_, value_, a_, b_, c_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 802, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 6; __pyx_t_6.hue_ = __pyx_v_hue_; __pyx_t_6.sat_ = __pyx_v_sat_; __pyx_t_6.value_ = __pyx_v_value_; __pyx_t_6.a_ = __pyx_v_a_; __pyx_t_6.b_ = __pyx_v_b_; __pyx_t_6.c_ = __pyx_v_c_; __pyx_f_6shader_shader_plasma24bit_inplace_c(__pyx_t_5, __pyx_v_frame, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0803:
0804:
+0805: cpdef inline void plasma(surface_, float frame, unsigned int [::1] palette_):
static PyObject *__pyx_pw_6shader_37plasma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_plasma(PyObject *__pyx_v_surface_, float __pyx_v_frame, __Pyx_memviewslice __pyx_v_palette_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plasma", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.plasma", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_37plasma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_36plasma[] = "\n CREATE A PLASMA EFFECT INPLACE\n\n e.g:\n plasma(surface, frame_number, palette_)\n \n :param surface_: pygame.Surface; compatible 24 - 32 bit \n :param frame : float; frame number\n :param palette_: 1d array containing colors\n :return:\n "; static PyObject *__pyx_pw_6shader_37plasma(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_frame; __Pyx_memviewslice __pyx_v_palette_ = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plasma (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_frame,&__pyx_n_s_palette,0}; PyObject* values[3] = {0,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 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_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_frame)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("plasma", 1, 3, 3, 1); __PYX_ERR(1, 805, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_palette)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("plasma", 1, 3, 3, 2); __PYX_ERR(1, 805, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "plasma") < 0)) __PYX_ERR(1, 805, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_surface_ = values[0]; __pyx_v_frame = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_frame == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 805, __pyx_L3_error) __pyx_v_palette_ = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_palette_.memview)) __PYX_ERR(1, 805, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("plasma", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 805, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.plasma", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_36plasma(__pyx_self, __pyx_v_surface_, __pyx_v_frame, __pyx_v_palette_); 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_6shader_36plasma(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_frame, __Pyx_memviewslice __pyx_v_palette_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("plasma", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_palette_.memview)) { __Pyx_RaiseUnboundLocalError("palette_"); __PYX_ERR(1, 805, __pyx_L1_error) } __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_plasma(__pyx_v_surface_, __pyx_v_frame, __pyx_v_palette_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 805, __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("shader.plasma", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_palette_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0806: """
0807: CREATE A PLASMA EFFECT INPLACE
0808:
0809: e.g:
0810: plasma(surface, frame_number, palette_)
0811:
0812: :param surface_: pygame.Surface; compatible 24 - 32 bit
0813: :param frame : float; frame number
0814: :param palette_: 1d array containing colors
0815: :return:
0816: """
+0817: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 817, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 817, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 817, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0818: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 818, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 817, __pyx_L1_error) } } #endif
+0819: shader_plasma_c(surface_, frame, palette_)
__pyx_f_6shader_shader_plasma_c(__pyx_v_surface_, __pyx_v_frame, __pyx_v_palette_);
0820:
0821:
0822: # todo wiki
+0823: cpdef inline float [:, :, :, ::1] rgb_to_hsl_model():
static PyObject *__pyx_pw_6shader_39rgb_to_hsl_model(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static CYTHON_INLINE __Pyx_memviewslice __pyx_f_6shader_rgb_to_hsl_model(CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_hsl_model", 0); /* … */ /* function exit code */ __pyx_L1_error:; __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("shader.rgb_to_hsl_model", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_39rgb_to_hsl_model(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6shader_38rgb_to_hsl_model[] = "\n Create an HSL model containing all the values\n :return: Return a cython.view.memoryview shape (256, 256, 256, 3)\n "; static PyObject *__pyx_pw_6shader_39rgb_to_hsl_model(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_hsl_model (wrapper)", 0); __pyx_r = __pyx_pf_6shader_38rgb_to_hsl_model(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_38rgb_to_hsl_model(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_hsl_model", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_rgb_to_hsl_model(0); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 823, __pyx_L1_error) __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_t_1, 4, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.rgb_to_hsl_model", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0824: """
0825: Create an HSL model containing all the values
0826: :return: Return a cython.view.memoryview shape (256, 256, 256, 3)
0827: """
+0828: return rgb_to_hsl_model_c()
__pyx_t_1 = __pyx_f_6shader_rgb_to_hsl_model_c(); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 828, __pyx_L1_error)
__pyx_r = __pyx_t_1;
__pyx_t_1.memview = NULL;
__pyx_t_1.data = NULL;
goto __pyx_L0;
0829:
0830:
0831: # todo wiki
+0832: cpdef inline unsigned char [:, :, :, ::1] hsl_to_rgb_model():
static PyObject *__pyx_pw_6shader_41hsl_to_rgb_model(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static CYTHON_INLINE __Pyx_memviewslice __pyx_f_6shader_hsl_to_rgb_model(CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_to_rgb_model", 0); /* … */ /* function exit code */ __pyx_L1_error:; __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("shader.hsl_to_rgb_model", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_41hsl_to_rgb_model(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ static char __pyx_doc_6shader_40hsl_to_rgb_model[] = "\n Create an RGB model containing all the values\n :return: Return a cython.view.memoryview shape (256, 256, 256, 3)\n "; static PyObject *__pyx_pw_6shader_41hsl_to_rgb_model(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_to_rgb_model (wrapper)", 0); __pyx_r = __pyx_pf_6shader_40hsl_to_rgb_model(__pyx_self); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_40hsl_to_rgb_model(CYTHON_UNUSED PyObject *__pyx_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_to_rgb_model", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_hsl_to_rgb_model(0); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 832, __pyx_L1_error) __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_t_1, 4, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __pyx_t_1.memview = NULL; __pyx_t_1.data = NULL; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __PYX_XDEC_MEMVIEW(&__pyx_t_1, 1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.hsl_to_rgb_model", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0833: """
0834: Create an RGB model containing all the values
0835: :return: Return a cython.view.memoryview shape (256, 256, 256, 3)
0836: """
+0837: return hsl_to_rgb_model_c()
__pyx_t_1 = __pyx_f_6shader_hsl_to_rgb_model_c(); if (unlikely(!__pyx_t_1.memview)) __PYX_ERR(1, 837, __pyx_L1_error)
__pyx_r = __pyx_t_1;
__pyx_t_1.memview = NULL;
__pyx_t_1.data = NULL;
goto __pyx_L0;
0838:
0839:
0840:
+0841: cpdef inline void brightness(object surface_, float shift_):
static PyObject *__pyx_pw_6shader_43brightness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_brightness(PyObject *__pyx_v_surface_, float __pyx_v_shift_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.brightness", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_43brightness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_42brightness[] = "\n SHADER BRIGHTNESS\n\n This shader control the pygame display brightness level\n It uses two external functions coded in C, struct_rgb_to_hsl & struct_hsl_to_rgb\n \n Parameter shift_ is a float value in range [ -1.0 ... 1.0]. with +1.0 for the \n maximum brightness. A value of 0.0 will not perform any changes to the original \n surface\n \n Compatible 24 - 32 bit with or without alpha layer\n \n * The changes are automatically applied inplace to the surface, you do not need to create a \n new surface. \n \n e.g:\n brightness(surface, 0.2)\n \n :param surface_ : pygame.surface; \n :param shift_ : float must be in range [ -1.0 ... 1.0 ]\n :return : void\n "; static PyObject *__pyx_pw_6shader_43brightness(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("brightness", 1, 2, 2, 1); __PYX_ERR(1, 841, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "brightness") < 0)) __PYX_ERR(1, 841, __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_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 841, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("brightness", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 841, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.brightness", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_42brightness(__pyx_self, __pyx_v_surface_, __pyx_v_shift_); 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_6shader_42brightness(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_brightness(__pyx_v_surface_, __pyx_v_shift_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 841, __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("shader.brightness", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0842: """
0843: SHADER BRIGHTNESS
0844:
0845: This shader control the pygame display brightness level
0846: It uses two external functions coded in C, struct_rgb_to_hsl & struct_hsl_to_rgb
0847:
0848: Parameter shift_ is a float value in range [ -1.0 ... 1.0]. with +1.0 for the
0849: maximum brightness. A value of 0.0 will not perform any changes to the original
0850: surface
0851:
0852: Compatible 24 - 32 bit with or without alpha layer
0853:
0854: * The changes are automatically applied inplace to the surface, you do not need to create a
0855: new surface.
0856:
0857: e.g:
0858: brightness(surface, 0.2)
0859:
0860: :param surface_ : pygame.surface;
0861: :param shift_ : float must be in range [ -1.0 ... 1.0 ]
0862: :return : void
0863: """
+0864: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 864, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0865: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 865, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 864, __pyx_L1_error) } } #endif
0866:
+0867: if shift_ == 0.0:
__pyx_t_3 = ((__pyx_v_shift_ == 0.0) != 0); if (__pyx_t_3) { /* … */ }
+0868: return
goto __pyx_L0;
0869:
+0870: assert -1.0 <= shift_ <= 1.0, "\nArgument shift_ must be in range [-1.0 ... 1.0]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift__must_be_in_rang); __PYX_ERR(1, 870, __pyx_L1_error) } } #endif
0871:
+0872: shader_brightness24_inplace_c(pixels3d(surface_), shift_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 872, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 1; __pyx_t_6.shift_ = __pyx_v_shift_; __pyx_f_6shader_shader_brightness24_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0873:
0874:
+0875: cpdef inline void brightness_exclude(
static PyObject *__pyx_pw_6shader_45brightness_exclude(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_brightness_exclude(PyObject *__pyx_v_surface_, float __pyx_v_shift_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_brightness_exclude *__pyx_optional_args) { /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.brightness_exclude", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_45brightness_exclude(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_44brightness_exclude[] = "\n\n INCREASE/DECREASE A SURFACE BRIGHTNESS (OPTIONAL EXCLUDE COLOR)\n \n The optional setting (color_) allow you to select a color that will not \n be included in the processing. This can be useful if you know the background \n color RGB values and do not wish the background to undergo a change in brightness \n \n Parameter shift_ is a float value in range [ -1.0 ... 1.0]. with +1.0 for the \n maximum brightness. A value of 0.0 will not perform any changes to the original \n surface\n \n Parameter color_ is a tuple of RGB colors e.g (1, 1, 1) \n\n :param surface_ : pygame.surface; \n :param shift_ : float must be in range [ -1.0 ... 1.0 ]\n :param color_ : tuple RGB to be excluded from the process\n :return : void\n "; static PyObject *__pyx_pw_6shader_45brightness_exclude(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; PyObject *__pyx_v_color_ = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_exclude (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,&__pyx_n_s_color,0}; PyObject* values[3] = {0,0,0}; /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_44brightness_exclude(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_, PyObject *__pyx_v_color_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_exclude", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.color_ = __pyx_v_color_; __pyx_f_6shader_brightness_exclude(__pyx_v_surface_, __pyx_v_shift_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.brightness_exclude", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0876: object surface_,
0877: float shift_,
+0878: color_=(0, 0, 0)
PyObject *__pyx_v_color_ = ((PyObject *)__pyx_tuple__9); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_exclude", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_color_ = __pyx_optional_args->color_; } } /* … */ values[2] = ((PyObject *)__pyx_tuple__9); 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_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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("brightness_exclude", 0, 2, 3, 1); __PYX_ERR(1, 875, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_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, "brightness_exclude") < 0)) __PYX_ERR(1, 875, __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); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_surface_ = values[0]; __pyx_v_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 877, __pyx_L3_error) __pyx_v_color_ = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("brightness_exclude", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 875, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.brightness_exclude", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_44brightness_exclude(__pyx_self, __pyx_v_surface_, __pyx_v_shift_, __pyx_v_color_); /* … */ __pyx_tuple__9 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 878, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9);
0879: ):
0880: """
0881:
0882: INCREASE/DECREASE A SURFACE BRIGHTNESS (OPTIONAL EXCLUDE COLOR)
0883:
0884: The optional setting (color_) allow you to select a color that will not
0885: be included in the processing. This can be useful if you know the background
0886: color RGB values and do not wish the background to undergo a change in brightness
0887:
0888: Parameter shift_ is a float value in range [ -1.0 ... 1.0]. with +1.0 for the
0889: maximum brightness. A value of 0.0 will not perform any changes to the original
0890: surface
0891:
0892: Parameter color_ is a tuple of RGB colors e.g (1, 1, 1)
0893:
0894: :param surface_ : pygame.surface;
0895: :param shift_ : float must be in range [ -1.0 ... 1.0 ]
0896: :param color_ : tuple RGB to be excluded from the process
0897: :return : void
0898: """
+0899: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 899, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0900: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 899, __pyx_L1_error) } } #endif
0901:
+0902: if shift_ == 0.0:
__pyx_t_3 = ((__pyx_v_shift_ == 0.0) != 0); if (__pyx_t_3) { /* … */ }
+0903: return
goto __pyx_L0;
0904:
+0905: assert -1.0 <= shift_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift__must_be_in_range); __PYX_ERR(1, 905, __pyx_L1_error) } } #endif
0906: "Argument shift_ must be in range[-1.0 ... 1.0]"
0907:
+0908: shader_brightness24_exclude_inplace_c(pixels3d(surface_), shift_, color_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 908, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 2; __pyx_t_6.shift_ = __pyx_v_shift_; __pyx_t_6.color_ = __pyx_v_color_; __pyx_f_6shader_shader_brightness24_exclude_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0909:
0910:
0911:
+0912: cpdef inline void brightness_bpf(
static PyObject *__pyx_pw_6shader_47brightness_bpf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_brightness_bpf(PyObject *__pyx_v_surface_, float __pyx_v_shift_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_brightness_bpf *__pyx_optional_args) { unsigned char __pyx_v_bpf_threshold = ((unsigned char)64); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_bpf", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_bpf_threshold = __pyx_optional_args->bpf_threshold; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.brightness_bpf", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_47brightness_bpf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_46brightness_bpf[] = "\n\n INCREASE/DECREASE SURFACE BRIGHTNESS \n\n bpf_threshold is an integer value in range [0..255] that \n determines the pixels threshold for the brightness algorithm. \n The sum RGB below this threshold will not be included in the process \n R + G + B < Threshold \n\n\n :param surface_: Pygame.Surface compatible 24 - 32 bit \n\n :param shift_: float, must be in range [-1.00 ... +1.00]\n\n :param bpf_threshold : integer value in range [0 ... 255].\n threshold RGB. Values R+G+B < threshold will not be included in the process\n :return: void \n\n "; static PyObject *__pyx_pw_6shader_47brightness_bpf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; unsigned char __pyx_v_bpf_threshold; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_bpf (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,&__pyx_n_s_bpf_threshold,0}; PyObject* values[3] = {0,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 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_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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("brightness_bpf", 0, 2, 3, 1); __PYX_ERR(1, 912, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bpf_threshold); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "brightness_bpf") < 0)) __PYX_ERR(1, 912, __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); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_surface_ = values[0]; __pyx_v_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 914, __pyx_L3_error) if (values[2]) { __pyx_v_bpf_threshold = __Pyx_PyInt_As_unsigned_char(values[2]); if (unlikely((__pyx_v_bpf_threshold == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 915, __pyx_L3_error) } else { __pyx_v_bpf_threshold = ((unsigned char)64); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("brightness_bpf", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 912, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.brightness_bpf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_46brightness_bpf(__pyx_self, __pyx_v_surface_, __pyx_v_shift_, __pyx_v_bpf_threshold); 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_6shader_46brightness_bpf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_, unsigned char __pyx_v_bpf_threshold) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_bpf", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.bpf_threshold = __pyx_v_bpf_threshold; __pyx_f_6shader_brightness_bpf(__pyx_v_surface_, __pyx_v_shift_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.brightness_bpf", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0913: object surface_,
0914: float shift_,
0915: unsigned char bpf_threshold = 64):
0916: """
0917:
0918: INCREASE/DECREASE SURFACE BRIGHTNESS
0919:
0920: bpf_threshold is an integer value in range [0..255] that
0921: determines the pixels threshold for the brightness algorithm.
0922: The sum RGB below this threshold will not be included in the process
0923: R + G + B < Threshold
0924:
0925:
0926: :param surface_: Pygame.Surface compatible 24 - 32 bit
0927:
0928: :param shift_: float, must be in range [-1.00 ... +1.00]
0929:
0930: :param bpf_threshold : integer value in range [0 ... 255].
0931: threshold RGB. Values R+G+B < threshold will not be included in the process
0932: :return: void
0933:
0934: """
+0935: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 935, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0936: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 936, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 935, __pyx_L1_error) } } #endif
0937:
+0938: assert -1.0 <= shift_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift_must_be_in_range); __PYX_ERR(1, 938, __pyx_L1_error) } } #endif
0939: "Argument shift must be in range[-1.0 ... 1.0]"
0940:
+0941: shader_brightness24_bpf_c(pixels3d(surface_), shift_, bpf_threshold)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 941, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 2; __pyx_t_6.shift_ = __pyx_v_shift_; __pyx_t_6.bpf_treshold_ = __pyx_v_bpf_threshold; __pyx_f_6shader_shader_brightness24_bpf_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0942:
0943:
+0944: cpdef inline void brightness_model(
static PyObject *__pyx_pw_6shader_49brightness_model(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_brightness_model(PyObject *__pyx_v_surface_, float __pyx_v_shift_, __Pyx_memviewslice __pyx_v_rgb_to_hsl_model, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_model", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.brightness_model", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_49brightness_model(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_48brightness_model[] = "\n \n SHADER BRIGHTNESS (EXCLUDE A SPECIFIC COLOR FROM THE PROCESS, DEFAULT BLACK COLOR)\n\n This shader control the pygame display brightness level\n It uses two external functions coded in C, struct_rgb_to_hsl & struct_hsl_to_rgb\n\n e.g:\n brightness_exclude(surface, 0.2)\n \n :param surface_ : pygame.surface; compatible 24 - 32 bit \n :param shift_ : float in range [-1.0 ... 1.0 ]\n :param rgb_to_hsl_model : numpy.ndarray shape (256, 256, 256, 3)\n :return : void \n "; static PyObject *__pyx_pw_6shader_49brightness_model(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; __Pyx_memviewslice __pyx_v_rgb_to_hsl_model = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_model (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,&__pyx_n_s_rgb_to_hsl_model,0}; PyObject* values[3] = {0,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 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_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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("brightness_model", 1, 3, 3, 1); __PYX_ERR(1, 944, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rgb_to_hsl_model)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("brightness_model", 1, 3, 3, 2); __PYX_ERR(1, 944, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "brightness_model") < 0)) __PYX_ERR(1, 944, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_surface_ = values[0]; __pyx_v_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 946, __pyx_L3_error) __pyx_v_rgb_to_hsl_model = __Pyx_PyObject_to_MemoryviewSlice_dsdsdsds_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_rgb_to_hsl_model.memview)) __PYX_ERR(1, 947, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("brightness_model", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 944, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.brightness_model", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_48brightness_model(__pyx_self, __pyx_v_surface_, __pyx_v_shift_, __pyx_v_rgb_to_hsl_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_6shader_48brightness_model(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_, __Pyx_memviewslice __pyx_v_rgb_to_hsl_model) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("brightness_model", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_rgb_to_hsl_model.memview)) { __Pyx_RaiseUnboundLocalError("rgb_to_hsl_model"); __PYX_ERR(1, 944, __pyx_L1_error) } __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_brightness_model(__pyx_v_surface_, __pyx_v_shift_, __pyx_v_rgb_to_hsl_model, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 944, __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("shader.brightness_model", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_to_hsl_model, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0945: object surface_,
0946: float shift_,
0947: float [:, :, :, :] rgb_to_hsl_model
0948: ):
0949: """
0950:
0951: SHADER BRIGHTNESS (EXCLUDE A SPECIFIC COLOR FROM THE PROCESS, DEFAULT BLACK COLOR)
0952:
0953: This shader control the pygame display brightness level
0954: It uses two external functions coded in C, struct_rgb_to_hsl & struct_hsl_to_rgb
0955:
0956: e.g:
0957: brightness_exclude(surface, 0.2)
0958:
0959: :param surface_ : pygame.surface; compatible 24 - 32 bit
0960: :param shift_ : float in range [-1.0 ... 1.0 ]
0961: :param rgb_to_hsl_model : numpy.ndarray shape (256, 256, 256, 3)
0962: :return : void
0963: """
+0964: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 964, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0965: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 965, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 964, __pyx_L1_error) } } #endif
0966:
+0967: warnings.warn("Deprecated version, use shader_brightness_24_inplace (fastest version)",
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__10 = PyTuple_Pack(2, __pyx_kp_s_Deprecated_version_use_shader_br, __pyx_builtin_DeprecationWarning); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 967, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10);
0968: DeprecationWarning)
+0969: assert -1.0 <= shift_ <= 1.0, "\nArgument shift_ must be in range [-1.0 ... 1.0]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift__must_be_in_rang); __PYX_ERR(1, 969, __pyx_L1_error) } } #endif
0970:
+0971: shader_brightness_24_inplace1_c(pixels3d(surface_), shift_, rgb_to_hsl_model)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 971, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_brightness_24_inplace1_c(__pyx_t_5, __pyx_v_shift_, __pyx_v_rgb_to_hsl_model); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0972:
0973:
0974:
0975:
+0976: cpdef inline void saturation(object surface_, float shift_):
static PyObject *__pyx_pw_6shader_51saturation(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_saturation(PyObject *__pyx_v_surface_, float __pyx_v_shift_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("saturation", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.saturation", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_51saturation(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_50saturation[] = "\n SHADER SATURATION\n\n This shader control the saturation level of the pygame display or surface/texture\n\n e.g:\n saturation(surface, 0.2)\n \n \n :param surface_: pygame.Surface; compatible 24 - 32 bit\n :param shift_ : float must be in range [ -1.0 ... 1.0] \n :return:\n "; static PyObject *__pyx_pw_6shader_51saturation(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_shift_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("saturation (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_shift,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_shift)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("saturation", 1, 2, 2, 1); __PYX_ERR(1, 976, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "saturation") < 0)) __PYX_ERR(1, 976, __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_shift_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_shift_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 976, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("saturation", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 976, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.saturation", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_50saturation(__pyx_self, __pyx_v_surface_, __pyx_v_shift_); 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_6shader_50saturation(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_shift_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("saturation", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_saturation(__pyx_v_surface_, __pyx_v_shift_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 976, __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("shader.saturation", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0977: """
0978: SHADER SATURATION
0979:
0980: This shader control the saturation level of the pygame display or surface/texture
0981:
0982: e.g:
0983: saturation(surface, 0.2)
0984:
0985:
0986: :param surface_: pygame.Surface; compatible 24 - 32 bit
0987: :param shift_ : float must be in range [ -1.0 ... 1.0]
0988: :return:
0989: """
+0990: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 990, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+0991: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 990, __pyx_L1_error) } } #endif
0992:
+0993: assert -1.0 <= shift_ <= 1.0, "\nArgument shift_ must be in range [-1.0 ... 1.0]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_3 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift__must_be_in_rang); __PYX_ERR(1, 993, __pyx_L1_error) } } #endif
0994:
+0995: shader_saturation_array24_inplace_c(pixels3d(surface_), shift_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 995, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_saturation_array24_inplace_c(__pyx_t_5, __pyx_v_shift_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
0996:
0997:
0998:
+0999: cpdef inline void heatwave_vertical(
static PyObject *__pyx_pw_6shader_53heatwave_vertical(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_heatwave_vertical(PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_mask, float __pyx_v_factor_, float __pyx_v_center_, float __pyx_v_sigma_, float __pyx_v_mu_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatwave_vertical", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.heatwave_vertical", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_53heatwave_vertical(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_52heatwave_vertical[] = "\n\n APPLY A GAUSSIAN TRANSFORMATION TO A SURFACE\n\n This effect can be use to simulate air turbulence or heat flow/convection\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :param mask : numpy.ndarray shape (x, y) uint8, (values 255 or 0).\n Apply transformation to the original array\n if the value @(x, y) is 255 else remain unchanged.\n :param factor_ : Control the maximum of the gaussian equation.\n No transformation if factor_ equal zero\n :param center_ : Control the center of the gaussian equation (if center_ equal zero,\n the Gauss equation is centered\n at x=0 and maximum is 0.4 with amplitude_ = 1.0)\n :param sigma_ : float; sigma value of the gauss equation\n :param mu_ : float; mu value of the gauss equation\n "; static PyObject *__pyx_pw_6shader_53heatwave_vertical(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; __Pyx_memviewslice __pyx_v_mask = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_factor_; float __pyx_v_center_; float __pyx_v_sigma_; float __pyx_v_mu_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatwave_vertical (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_mask,&__pyx_n_s_factor,&__pyx_n_s_center,&__pyx_n_s_sigma,&__pyx_n_s_mu,0}; PyObject* values[6] = {0,0,0,0,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 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_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_mask)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("heatwave_vertical", 1, 6, 6, 1); __PYX_ERR(1, 999, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("heatwave_vertical", 1, 6, 6, 2); __PYX_ERR(1, 999, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_center)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("heatwave_vertical", 1, 6, 6, 3); __PYX_ERR(1, 999, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("heatwave_vertical", 1, 6, 6, 4); __PYX_ERR(1, 999, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mu)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("heatwave_vertical", 1, 6, 6, 5); __PYX_ERR(1, 999, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "heatwave_vertical") < 0)) __PYX_ERR(1, 999, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 6) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); } __pyx_v_surface_ = values[0]; __pyx_v_mask = __Pyx_PyObject_to_MemoryviewSlice_dsds_unsigned_char(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_mask.memview)) __PYX_ERR(1, 1001, __pyx_L3_error) __pyx_v_factor_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_factor_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1002, __pyx_L3_error) __pyx_v_center_ = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_center_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1003, __pyx_L3_error) __pyx_v_sigma_ = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_sigma_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1004, __pyx_L3_error) __pyx_v_mu_ = __pyx_PyFloat_AsFloat(values[5]); if (unlikely((__pyx_v_mu_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1005, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("heatwave_vertical", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 999, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.heatwave_vertical", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_52heatwave_vertical(__pyx_self, __pyx_v_surface_, __pyx_v_mask, __pyx_v_factor_, __pyx_v_center_, __pyx_v_sigma_, __pyx_v_mu_); 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_6shader_52heatwave_vertical(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_mask, float __pyx_v_factor_, float __pyx_v_center_, float __pyx_v_sigma_, float __pyx_v_mu_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatwave_vertical", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_mask.memview)) { __Pyx_RaiseUnboundLocalError("mask"); __PYX_ERR(1, 999, __pyx_L1_error) } __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_heatwave_vertical(__pyx_v_surface_, __pyx_v_mask, __pyx_v_factor_, __pyx_v_center_, __pyx_v_sigma_, __pyx_v_mu_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 999, __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("shader.heatwave_vertical", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_mask, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1000: object surface_,
1001: unsigned char [:, :] mask,
1002: float factor_,
1003: float center_,
1004: float sigma_,
1005: float mu_):
1006: """
1007:
1008: APPLY A GAUSSIAN TRANSFORMATION TO A SURFACE
1009:
1010: This effect can be use to simulate air turbulence or heat flow/convection
1011:
1012: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1013: :param mask : numpy.ndarray shape (x, y) uint8, (values 255 or 0).
1014: Apply transformation to the original array
1015: if the value @(x, y) is 255 else remain unchanged.
1016: :param factor_ : Control the maximum of the gaussian equation.
1017: No transformation if factor_ equal zero
1018: :param center_ : Control the center of the gaussian equation (if center_ equal zero,
1019: the Gauss equation is centered
1020: at x=0 and maximum is 0.4 with amplitude_ = 1.0)
1021: :param sigma_ : float; sigma value of the gauss equation
1022: :param mu_ : float; mu value of the gauss equation
1023: """
+1024: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1024, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1025: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1025, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1024, __pyx_L1_error) } } #endif
1026:
+1027: assert PyObject_IsInstance(mask, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_mask, 2, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1027, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1027, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1027, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1027, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1027, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1028: "\nArgument mask must be a numpy.array or memoryview type, got %s " % type(mask)
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mask, 2, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1028, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_mask_must_be_a_numpy_a, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1028, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1027, __pyx_L1_error) } } #endif
1029:
+1030: shader_heatwave24_vertical_inplace_c(pixels3d(surface_), mask, factor_, center_, sigma_, mu_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1030, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1030, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1030, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_heatwave24_vertical_inplace_c(__pyx_t_5, __pyx_v_mask, __pyx_v_factor_, __pyx_v_center_, __pyx_v_sigma_, __pyx_v_mu_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
1031:
1032:
1033:
+1034: cpdef inline void horizontal_glitch(
static PyObject *__pyx_pw_6shader_55horizontal_glitch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_horizontal_glitch(PyObject *__pyx_v_surface_, float __pyx_v_rad1_, float __pyx_v_frequency_, float __pyx_v_amplitude_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("horizontal_glitch", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.horizontal_glitch", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_55horizontal_glitch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_54horizontal_glitch[] = "\n SHADER GLITCH EFFECT\n\n Deform the pygame display to create a glitch effect\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :param rad1_ : float; Angle in radians, this value control the angle variation over the time\n :param frequency_: float; signal frequency, factor that amplify the angle variation\n :param amplitude_: float; cos amplitude value\n :return: void\n "; static PyObject *__pyx_pw_6shader_55horizontal_glitch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; float __pyx_v_rad1_; float __pyx_v_frequency_; float __pyx_v_amplitude_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("horizontal_glitch (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_rad1,&__pyx_n_s_frequency,&__pyx_n_s_amplitude,0}; PyObject* values[4] = {0,0,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 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_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_rad1)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("horizontal_glitch", 1, 4, 4, 1); __PYX_ERR(1, 1034, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_frequency)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("horizontal_glitch", 1, 4, 4, 2); __PYX_ERR(1, 1034, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_amplitude)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("horizontal_glitch", 1, 4, 4, 3); __PYX_ERR(1, 1034, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "horizontal_glitch") < 0)) __PYX_ERR(1, 1034, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_surface_ = values[0]; __pyx_v_rad1_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_rad1_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1036, __pyx_L3_error) __pyx_v_frequency_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_frequency_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1037, __pyx_L3_error) __pyx_v_amplitude_ = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_amplitude_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1038, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("horizontal_glitch", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1034, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.horizontal_glitch", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_54horizontal_glitch(__pyx_self, __pyx_v_surface_, __pyx_v_rad1_, __pyx_v_frequency_, __pyx_v_amplitude_); 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_6shader_54horizontal_glitch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, float __pyx_v_rad1_, float __pyx_v_frequency_, float __pyx_v_amplitude_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("horizontal_glitch", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_horizontal_glitch(__pyx_v_surface_, __pyx_v_rad1_, __pyx_v_frequency_, __pyx_v_amplitude_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1034, __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("shader.horizontal_glitch", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1035: object surface_,
1036: float rad1_,
1037: float frequency_,
1038: float amplitude_
1039: ):
1040: """
1041: SHADER GLITCH EFFECT
1042:
1043: Deform the pygame display to create a glitch effect
1044:
1045: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1046: :param rad1_ : float; Angle in radians, this value control the angle variation over the time
1047: :param frequency_: float; signal frequency, factor that amplify the angle variation
1048: :param amplitude_: float; cos amplitude value
1049: :return: void
1050: """
+1051: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1051, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1052: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1052, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1051, __pyx_L1_error) } } #endif
1053:
+1054: shader_horizontal_glitch24_inplace_c(pixels3d(surface_), rad1_, frequency_, amplitude_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1054, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_horizontal_glitch24_inplace_c(__pyx_t_5, __pyx_v_rad1_, __pyx_v_frequency_, __pyx_v_amplitude_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
1055:
1056:
1057:
+1058: cpdef inline void bpf(object surface_, int threshold = 128):
static PyObject *__pyx_pw_6shader_57bpf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_bpf(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_bpf *__pyx_optional_args) { int __pyx_v_threshold = ((int)0x80); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bpf", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold = __pyx_optional_args->threshold; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.bpf", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_57bpf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_56bpf[] = "\n \n SHADER BRIGHT PASS FILTER (INPLACE)\n\n Conserve only the brightest pixels in a surface\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :param threshold: integer; Bright pass threshold default 128\n :return: void \n "; static PyObject *__pyx_pw_6shader_57bpf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_threshold; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bpf (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_threshold_2,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_threshold_2); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bpf") < 0)) __PYX_ERR(1, 1058, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_threshold = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_threshold == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1058, __pyx_L3_error) } else { __pyx_v_threshold = ((int)0x80); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("bpf", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1058, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.bpf", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_56bpf(__pyx_self, __pyx_v_surface_, __pyx_v_threshold); 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_6shader_56bpf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_threshold) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bpf", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.threshold = __pyx_v_threshold; __pyx_f_6shader_bpf(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.bpf", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1059: """
1060:
1061: SHADER BRIGHT PASS FILTER (INPLACE)
1062:
1063: Conserve only the brightest pixels in a surface
1064:
1065: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1066: :param threshold: integer; Bright pass threshold default 128
1067: :return: void
1068: """
+1069: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1069, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1070: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1069, __pyx_L1_error) } } #endif
1071:
+1072: shader_bpf24_inplace_c(pixels3d(surface_), threshold)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1072, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6.__pyx_n = 1; __pyx_t_6.threshold = __pyx_v_threshold; __pyx_f_6shader_shader_bpf24_inplace_c(__pyx_t_5, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
1073:
1074:
1075:
+1076: cpdef inline void bloom(object surface_, int threshold_, bint fast_=False):
static PyObject *__pyx_pw_6shader_59bloom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_bloom(PyObject *__pyx_v_surface_, int __pyx_v_threshold_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_bloom *__pyx_optional_args) { int __pyx_v_fast_ = ((int)0); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bloom", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_fast_ = __pyx_optional_args->fast_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.bloom", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_59bloom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_58bloom[] = "\n \n CREATE A BLOOM EFFECT\n\n * Surface must be a pygame Surface 24-32 bit format\n\n :param surface_ : pygame.Surface; Game display or texture\n :param threshold_ : integer; Threshold value uint8 in range [0 ... 255].\n The threshold value is used by a bright\n pass filter to determine the bright pixels above the given threshold.\n Below 128 the bloom effect will be more\n noticeable and above 128 a bit less.\n :param fast_ : bool; True | False; If True the bloom effect will be approximated\n and only the x16 subsurface\n will be processed to maximize the overall processing time, \n default is False).\n :return : void\n \n "; static PyObject *__pyx_pw_6shader_59bloom(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_threshold_; int __pyx_v_fast_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bloom (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_threshold,&__pyx_n_s_fast,0}; PyObject* values[3] = {0,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 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_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_threshold)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("bloom", 0, 2, 3, 1); __PYX_ERR(1, 1076, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fast); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bloom") < 0)) __PYX_ERR(1, 1076, __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); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_surface_ = values[0]; __pyx_v_threshold_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_threshold_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1076, __pyx_L3_error) if (values[2]) { __pyx_v_fast_ = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_fast_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1076, __pyx_L3_error) } else { __pyx_v_fast_ = ((int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("bloom", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1076, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.bloom", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_58bloom(__pyx_self, __pyx_v_surface_, __pyx_v_threshold_, __pyx_v_fast_); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_58bloom(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_threshold_, int __pyx_v_fast_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bloom", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.fast_ = __pyx_v_fast_; __pyx_f_6shader_bloom(__pyx_v_surface_, __pyx_v_threshold_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.bloom", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1077: """
1078:
1079: CREATE A BLOOM EFFECT
1080:
1081: * Surface must be a pygame Surface 24-32 bit format
1082:
1083: :param surface_ : pygame.Surface; Game display or texture
1084: :param threshold_ : integer; Threshold value uint8 in range [0 ... 255].
1085: The threshold value is used by a bright
1086: pass filter to determine the bright pixels above the given threshold.
1087: Below 128 the bloom effect will be more
1088: noticeable and above 128 a bit less.
1089: :param fast_ : bool; True | False; If True the bloom effect will be approximated
1090: and only the x16 subsurface
1091: will be processed to maximize the overall processing time,
1092: default is False).
1093: :return : void
1094:
1095: """
+1096: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1096, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1097: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1097, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1096, __pyx_L1_error) } } #endif
1098:
+1099: shader_bloom_effect_array24_c(surface_, threshold_, fast_)
__pyx_t_4.__pyx_n = 1; __pyx_t_4.fast_ = __pyx_v_fast_; __pyx_f_6shader_shader_bloom_effect_array24_c(__pyx_v_surface_, __pyx_v_threshold_, &__pyx_t_4);
1100:
1101:
1102:
+1103: cpdef inline fisheye_footprint(int w, int h):
static PyObject *__pyx_pw_6shader_61fisheye_footprint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_fisheye_footprint(int __pyx_v_w, int __pyx_v_h, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fisheye_footprint", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("shader.fisheye_footprint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_61fisheye_footprint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_60fisheye_footprint[] = "\n\n :param w: integer; width of the fisheye model\n :param h: integer; height of the fisheye model\n :return: Return a numpy.ndarray type (w, h, 2) representing the fisheye model (coordinates\n of all surface pixels passing through the fisheye lens model)\n "; static PyObject *__pyx_pw_6shader_61fisheye_footprint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_w; int __pyx_v_h; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fisheye_footprint (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_w,&__pyx_n_s_h,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_w)) != 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_h)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fisheye_footprint", 1, 2, 2, 1); __PYX_ERR(1, 1103, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fisheye_footprint") < 0)) __PYX_ERR(1, 1103, __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_w = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_w == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1103, __pyx_L3_error) __pyx_v_h = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_h == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1103, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fisheye_footprint", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1103, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.fisheye_footprint", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_60fisheye_footprint(__pyx_self, __pyx_v_w, __pyx_v_h); 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_6shader_60fisheye_footprint(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_w, int __pyx_v_h) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fisheye_footprint", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_fisheye_footprint(__pyx_v_w, __pyx_v_h, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1103, __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("shader.fisheye_footprint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1104: """
1105:
1106: :param w: integer; width of the fisheye model
1107: :param h: integer; height of the fisheye model
1108: :return: Return a numpy.ndarray type (w, h, 2) representing the fisheye model (coordinates
1109: of all surface pixels passing through the fisheye lens model)
1110: """
+1111: return shader_fisheye24_footprint_c(w, h)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_shader_fisheye24_footprint_c(__pyx_v_w, __pyx_v_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1112:
1113:
1114:
1115:
+1116: cpdef inline void fisheye(
static PyObject *__pyx_pw_6shader_63fisheye(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_fisheye(PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_fisheye_model, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fisheye", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.fisheye", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_63fisheye(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_62fisheye[] = "\n THIS SHADER CAN BE USE TO DISPLAY THE GAME THROUGH A LENS EFFECT\n\n Display a fisheye effect in real time given a surface referencing the\n pixels RGB. In order to accomplish a real time calculation, \n this algorithm is using a pre-calculated transformation stored\n in the array fisheye_model.\n \n The function shader_fisheye24_footprint_c has to be called prior\n shader_fisheye24_inplace_c in order to store the transformation values.\n\n This shader can be applied directly to the pygame display\n\n :param fisheye_model : numpy.ndarray shape (width, height, 2) int32, fisheye model\n containing the pixels\n coordinates after the fisheye transformation\n :return : void\n \n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :param fisheye_model : numpy.ndarray or cython memoryview shape (width, height, 2) int32, \n fisheye model containing the pixels\n :return: void \n "; static PyObject *__pyx_pw_6shader_63fisheye(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; __Pyx_memviewslice __pyx_v_fisheye_model = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fisheye (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_fisheye_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_fisheye_model)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fisheye", 1, 2, 2, 1); __PYX_ERR(1, 1116, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fisheye") < 0)) __PYX_ERR(1, 1116, __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_fisheye_model = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_fisheye_model.memview)) __PYX_ERR(1, 1117, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fisheye", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1116, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.fisheye", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_62fisheye(__pyx_self, __pyx_v_surface_, __pyx_v_fisheye_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_6shader_62fisheye(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_fisheye_model) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fisheye", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_fisheye_model.memview)) { __Pyx_RaiseUnboundLocalError("fisheye_model"); __PYX_ERR(1, 1116, __pyx_L1_error) } __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_fisheye(__pyx_v_surface_, __pyx_v_fisheye_model, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1116, __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("shader.fisheye", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_fisheye_model, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1117: object surface_, unsigned int [:, :, :] fisheye_model):
1118: """
1119: THIS SHADER CAN BE USE TO DISPLAY THE GAME THROUGH A LENS EFFECT
1120:
1121: Display a fisheye effect in real time given a surface referencing the
1122: pixels RGB. In order to accomplish a real time calculation,
1123: this algorithm is using a pre-calculated transformation stored
1124: in the array fisheye_model.
1125:
1126: The function shader_fisheye24_footprint_c has to be called prior
1127: shader_fisheye24_inplace_c in order to store the transformation values.
1128:
1129: This shader can be applied directly to the pygame display
1130:
1131: :param fisheye_model : numpy.ndarray shape (width, height, 2) int32, fisheye model
1132: containing the pixels
1133: coordinates after the fisheye transformation
1134: :return : void
1135:
1136: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1137: :param fisheye_model : numpy.ndarray or cython memoryview shape (width, height, 2) int32,
1138: fisheye model containing the pixels
1139: :return: void
1140: """
1141:
1142: # TODO EXPERIMENT WITH ORDER = 'C'
+1143: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1144: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1143, __pyx_L1_error) } } #endif
1145:
+1146: assert PyObject_IsInstance(fisheye_model, (cython.view.memoryview, numpy.ndarray)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1146, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1146, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
1147: "\nArgument fisheye_model must be a numpy.ndarray or a cython.view.memoryview type, " \
+1148: "got %s " % type(fisheye_model)
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_fisheye_model_must_be, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1146, __pyx_L1_error) } } #endif
1149:
+1150: shader_fisheye24_inplace_c(pixels3d(surface_), fisheye_model)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1150, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_fisheye24_inplace_c(__pyx_t_5, __pyx_v_fisheye_model); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
1151:
1152:
1153:
1154: # TODO DOC
+1155: cpdef inline tuple rain_footprint(int w, int h):
static PyObject *__pyx_pw_6shader_65rain_footprint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_rain_footprint(int __pyx_v_w, int __pyx_v_h, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rain_footprint", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("shader.rain_footprint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_65rain_footprint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_64rain_footprint[] = "\n \n CREATE A FISH EYE LENS DEFORMATION MAP/TEXTURE\n\n * This function create a texture and its equivalent numpy.ndarray containing the coordinates\n for each pixels after deformation.\n * This method must be called once outside of your game main loop\n * The model can be re-use to display your video game animation without being re-calculated for\n each frame. This method allow a high FPS rate\n\n :param w : integer; Width of the fish eye effect\n :param h : integer; height of the fish eye effect\n :return : Pygame Surface representing the fish-eye effect and its\n equivalent numpy.ndarray\n "; static PyObject *__pyx_pw_6shader_65rain_footprint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_w; int __pyx_v_h; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rain_footprint (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_w,&__pyx_n_s_h,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_w)) != 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_h)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rain_footprint", 1, 2, 2, 1); __PYX_ERR(1, 1155, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rain_footprint") < 0)) __PYX_ERR(1, 1155, __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_w = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_w == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1155, __pyx_L3_error) __pyx_v_h = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_h == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1155, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rain_footprint", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1155, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.rain_footprint", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_64rain_footprint(__pyx_self, __pyx_v_w, __pyx_v_h); 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_6shader_64rain_footprint(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_w, int __pyx_v_h) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rain_footprint", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_rain_footprint(__pyx_v_w, __pyx_v_h, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1155, __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("shader.rain_footprint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1156: """
1157:
1158: CREATE A FISH EYE LENS DEFORMATION MAP/TEXTURE
1159:
1160: * This function create a texture and its equivalent numpy.ndarray containing the coordinates
1161: for each pixels after deformation.
1162: * This method must be called once outside of your game main loop
1163: * The model can be re-use to display your video game animation without being re-calculated for
1164: each frame. This method allow a high FPS rate
1165:
1166: :param w : integer; Width of the fish eye effect
1167: :param h : integer; height of the fish eye effect
1168: :return : Pygame Surface representing the fish-eye effect and its
1169: equivalent numpy.ndarray
1170: """
+1171: return shader_rain_footprint_inplace_c(w, h)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_shader_rain_footprint_inplace_c(__pyx_v_w, __pyx_v_h); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0;
1172:
1173:
1174:
1175:
1176: # TODO DOC
+1177: cpdef inline void rain_fisheye(
static PyObject *__pyx_pw_6shader_67rain_fisheye(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_rain_fisheye(PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_rain_fisheye_model, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rain_fisheye", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.rain_fisheye", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_67rain_fisheye(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_66rain_fisheye[] = "\n THIS SHADER CAN BE USED TO SIMULATE RAIN DROPLET OR BUBBLE DISPLAYED ON THE TOP OF\n THE SCREEN SURFACE.\n\n Both surface and rain_fisheye_model must have the exact same size\n\n 1) Always call the method shader_rain_footprint_inplace_c before the main loop.\n The transformation model doesn't have to be calculated every frames.\n The above method will generate a pygame texture (24bit) containing the location\n of each pixels after deformation. It does also return a numpy.ndarray equivalent\n pixel format that can be used instead of the surface if needed.\n\n It uses a fish eye lens deformation to reproduce the deformed background image onto\n the final image. The operation apply inplace and the surface referenced by the rgb_array_\n will be modified directly.\n The fish-eye lens deformation will recreate you game scene into the rain droplet or bubble\n and create the illusion of animation inside the bubble.\n\n * This shader cannot be applied directly to the pygame display as the array passed to the\n function is a scaled format of the pygame.display (copy not referencing directly the\n surface pixels)\n\n * This algorithm use a pre-calculated fish-eye lens deformation model to boost the overall\n FPS performances, the texture pixel is then transformed with the model without any intensive\n math calculation.\n\n :param surface_ : pygame.Surface compatible 24 - 32 bit \n :param rain_fisheye_model : numpy.ndarray or memoryview type (w, h, 3) unsigned int \n containing the the coordinate for each pixels\n :return : void\n\n "; static PyObject *__pyx_pw_6shader_67rain_fisheye(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; __Pyx_memviewslice __pyx_v_rain_fisheye_model = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rain_fisheye (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_rain_fisheye_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_rain_fisheye_model)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rain_fisheye", 1, 2, 2, 1); __PYX_ERR(1, 1177, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rain_fisheye") < 0)) __PYX_ERR(1, 1177, __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_rain_fisheye_model = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_rain_fisheye_model.memview)) __PYX_ERR(1, 1179, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rain_fisheye", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1177, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.rain_fisheye", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_66rain_fisheye(__pyx_self, __pyx_v_surface_, __pyx_v_rain_fisheye_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_6shader_66rain_fisheye(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_rain_fisheye_model) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rain_fisheye", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_rain_fisheye_model.memview)) { __Pyx_RaiseUnboundLocalError("rain_fisheye_model"); __PYX_ERR(1, 1177, __pyx_L1_error) } __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_rain_fisheye(__pyx_v_surface_, __pyx_v_rain_fisheye_model, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1177, __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("shader.rain_fisheye", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rain_fisheye_model, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1178: object surface_,
1179: unsigned int [:, :, ::1] rain_fisheye_model
1180: ):
1181: """
1182: THIS SHADER CAN BE USED TO SIMULATE RAIN DROPLET OR BUBBLE DISPLAYED ON THE TOP OF
1183: THE SCREEN SURFACE.
1184:
1185: Both surface and rain_fisheye_model must have the exact same size
1186:
1187: 1) Always call the method shader_rain_footprint_inplace_c before the main loop.
1188: The transformation model doesn't have to be calculated every frames.
1189: The above method will generate a pygame texture (24bit) containing the location
1190: of each pixels after deformation. It does also return a numpy.ndarray equivalent
1191: pixel format that can be used instead of the surface if needed.
1192:
1193: It uses a fish eye lens deformation to reproduce the deformed background image onto
1194: the final image. The operation apply inplace and the surface referenced by the rgb_array_
1195: will be modified directly.
1196: The fish-eye lens deformation will recreate you game scene into the rain droplet or bubble
1197: and create the illusion of animation inside the bubble.
1198:
1199: * This shader cannot be applied directly to the pygame display as the array passed to the
1200: function is a scaled format of the pygame.display (copy not referencing directly the
1201: surface pixels)
1202:
1203: * This algorithm use a pre-calculated fish-eye lens deformation model to boost the overall
1204: FPS performances, the texture pixel is then transformed with the model without any intensive
1205: math calculation.
1206:
1207: :param surface_ : pygame.Surface compatible 24 - 32 bit
1208: :param rain_fisheye_model : numpy.ndarray or memoryview type (w, h, 3) unsigned int
1209: containing the the coordinate for each pixels
1210: :return : void
1211:
1212: """
+1213: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1213, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1214: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1213, __pyx_L1_error) } } #endif
1215:
+1216: assert PyObject_IsInstance(rain_fisheye_model, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_rain_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
1217: "\nArgument rain_fisheye_model must be a " \
+1218: "numpy.ndarray or a cython memoryview type, got %s " % type(rain_fisheye_model)
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_rain_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_rain_fisheye_model_mus, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1216, __pyx_L1_error) } } #endif
1219:
+1220: shader_rain_fisheye24_inplace_c(pixels3d(surface_), rain_fisheye_model)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1220, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_rain_fisheye24_inplace_c(__pyx_t_5, __pyx_v_rain_fisheye_model); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
1221:
1222:
1223:
1224:
+1225: cpdef inline void tv_scan(surface_, int space=5):
static PyObject *__pyx_pw_6shader_69tv_scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_tv_scan(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_tv_scan *__pyx_optional_args) { int __pyx_v_space = ((int)5); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tv_scan", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_space = __pyx_optional_args->space; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.tv_scan", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_69tv_scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_68tv_scan[] = "\n \n SHADER CREATING A TV SCANLINE EFFECT ON PYGAME SURFACE\n\n The space between each scanline can by adjusted with the space value.\n The scanline intensity/colors is lower that the original image\n\n :param surface_ : pygame.Surface compatible 24-32 bit \n :param space : integer; space between the lines\n :return : void\n \n "; static PyObject *__pyx_pw_6shader_69tv_scan(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_space; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tv_scan (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_space,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_space); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tv_scan") < 0)) __PYX_ERR(1, 1225, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_space = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_space == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1225, __pyx_L3_error) } else { __pyx_v_space = ((int)5); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("tv_scan", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1225, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.tv_scan", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_68tv_scan(__pyx_self, __pyx_v_surface_, __pyx_v_space); 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_6shader_68tv_scan(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_space) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tv_scan", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.space = __pyx_v_space; __pyx_f_6shader_tv_scan(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.tv_scan", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1226: """
1227:
1228: SHADER CREATING A TV SCANLINE EFFECT ON PYGAME SURFACE
1229:
1230: The space between each scanline can by adjusted with the space value.
1231: The scanline intensity/colors is lower that the original image
1232:
1233: :param surface_ : pygame.Surface compatible 24-32 bit
1234: :param space : integer; space between the lines
1235: :return : void
1236:
1237: """
1238: # TODO SCANLINE VERTICAL | HORIZONTAL
1239:
+1240: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1240, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1241: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1240, __pyx_L1_error) } } #endif
1242:
+1243: assert space > 0, "Argument space cannot be <=0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_space > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_space_cannot_be_0); __PYX_ERR(1, 1243, __pyx_L1_error) } } #endif
1244:
+1245: shader_tv_scanline_inplace_c(pixels3d(surface_), space)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1245, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_tv_scanline_inplace_c(__pyx_t_5, __pyx_v_space); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
1246:
1247:
1248:
1249:
+1250: cpdef inline void rgb_split(object surface_, int offset_=10):
static PyObject *__pyx_pw_6shader_71rgb_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_rgb_split(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_rgb_split *__pyx_optional_args) { int __pyx_v_offset_ = ((int)10); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_split", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_offset_ = __pyx_optional_args->offset_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.rgb_split", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_71rgb_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_70rgb_split[] = "\n \n THIS SHADER CREATE AN RGB SPLIT EFFECT (SUPERPOSED CHANNEL R, G, B WITH GIVEN OFFSET)\n The transformation apply inplace\n\n The original surface will be used and used for the subsurface blit operation.\n Each channels will be blit sequentially in the following order RGB\n Note that channel green and blue will be blit with an additional flag BLEND_RGB_ADD, to mix\n the channel with the lower layers.\n\n * FPS BOOST\n In order to boost the fps frame rate the original surface to process can be downscale x2\n and rescale after processing.\n\n\n :param surface_ : pygame Surface to process (24bit format)\n :param offset_ : integer; offset for (x, y) to add to each channels RGB\n :return : void\n \n "; static PyObject *__pyx_pw_6shader_71rgb_split(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_offset_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_split (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_offset,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rgb_split") < 0)) __PYX_ERR(1, 1250, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_offset_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_offset_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1250, __pyx_L3_error) } else { __pyx_v_offset_ = ((int)10); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rgb_split", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1250, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.rgb_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_70rgb_split(__pyx_self, __pyx_v_surface_, __pyx_v_offset_); 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_6shader_70rgb_split(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_offset_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_split", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.offset_ = __pyx_v_offset_; __pyx_f_6shader_rgb_split(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.rgb_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1251: """
1252:
1253: THIS SHADER CREATE AN RGB SPLIT EFFECT (SUPERPOSED CHANNEL R, G, B WITH GIVEN OFFSET)
1254: The transformation apply inplace
1255:
1256: The original surface will be used and used for the subsurface blit operation.
1257: Each channels will be blit sequentially in the following order RGB
1258: Note that channel green and blue will be blit with an additional flag BLEND_RGB_ADD, to mix
1259: the channel with the lower layers.
1260:
1261: * FPS BOOST
1262: In order to boost the fps frame rate the original surface to process can be downscale x2
1263: and rescale after processing.
1264:
1265:
1266: :param surface_ : pygame Surface to process (24bit format)
1267: :param offset_ : integer; offset for (x, y) to add to each channels RGB
1268: :return : void
1269:
1270: """
+1271: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1271, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1272: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1271, __pyx_L1_error) } } #endif
1273:
+1274: shader_rgb_split_inplace_c(surface_, offset_)
__pyx_f_6shader_shader_rgb_split_inplace_c(__pyx_v_surface_, __pyx_v_offset_);
1275:
1276:
1277:
+1278: cpdef object rgb_split_clean(object surface_, int offset_=10):
static PyObject *__pyx_pw_6shader_73rgb_split_clean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_rgb_split_clean(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_rgb_split_clean *__pyx_optional_args) { int __pyx_v_offset_ = ((int)10); PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_split_clean", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_offset_ = __pyx_optional_args->offset_; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.rgb_split_clean", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_73rgb_split_clean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_72rgb_split_clean[] = "\n\n THIS SHADER CREATE AN RGB SPLIT EFFECT (SUPERPOSED CHANNEL R, G, B WITH GIVEN OFFSET)\n The final image has a different width and height since the offset value is removed to keep only \n the overlapping R, G, B channels \n Setting the Offset_ to zero will have no effect to the original image.\n\n :param surface_ : pygame Surface to process (24bit format)\n :param offset_ : integer; offset for (x, y) to add to each channels RGB\n :return : void\n\n "; static PyObject *__pyx_pw_6shader_73rgb_split_clean(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_offset_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_split_clean (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_offset,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_offset); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rgb_split_clean") < 0)) __PYX_ERR(1, 1278, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_offset_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_offset_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1278, __pyx_L3_error) } else { __pyx_v_offset_ = ((int)10); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rgb_split_clean", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1278, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.rgb_split_clean", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_72rgb_split_clean(__pyx_self, __pyx_v_surface_, __pyx_v_offset_); 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_6shader_72rgb_split_clean(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_offset_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_split_clean", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.offset_ = __pyx_v_offset_; __pyx_t_1 = __pyx_f_6shader_rgb_split_clean(__pyx_v_surface_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1278, __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("shader.rgb_split_clean", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1279: """
1280:
1281: THIS SHADER CREATE AN RGB SPLIT EFFECT (SUPERPOSED CHANNEL R, G, B WITH GIVEN OFFSET)
1282: The final image has a different width and height since the offset value is removed to keep only
1283: the overlapping R, G, B channels
1284: Setting the Offset_ to zero will have no effect to the original image.
1285:
1286: :param surface_ : pygame Surface to process (24bit format)
1287: :param offset_ : integer; offset for (x, y) to add to each channels RGB
1288: :return : void
1289:
1290: """
+1291: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1291, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1292: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1291, __pyx_L1_error) } } #endif
1293:
+1294: assert isinstance(offset_, int), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_offset_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyInt_Check(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1295: "\nArgument offset_ must be an int type, got %s" % type(offset_)
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_offset_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_offset__must_be_an_int, ((PyObject *)Py_TYPE(__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 1294, __pyx_L1_error) } } #endif
1296:
+1297: if offset_==0:
__pyx_t_3 = ((__pyx_v_offset_ == 0) != 0); if (__pyx_t_3) { /* … */ }
+1298: return surface_
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_surface_); __pyx_r = __pyx_v_surface_; goto __pyx_L0;
1299:
+1300: return shader_rgb_split_c(surface_, offset_)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_shader_rgb_split_c(__pyx_v_surface_, __pyx_v_offset_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1301:
1302:
1303:
1304:
+1305: cpdef inline tuple ripple(
static PyObject *__pyx_pw_6shader_75ripple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_ripple(int __pyx_v_rows_, int __pyx_v_cols_, __Pyx_memviewslice __pyx_v_previous_, __Pyx_memviewslice __pyx_v_current_, __Pyx_memviewslice __pyx_v_array_, CYTHON_UNUSED int __pyx_skip_dispatch) { Py_ssize_t __pyx_v_prev_w; Py_ssize_t __pyx_v_prev_h; Py_ssize_t __pyx_v_curr_w; Py_ssize_t __pyx_v_curr_h; Py_ssize_t __pyx_v_arr_w; Py_ssize_t __pyx_v_arr_h; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ripple", 0); /* … */ /* 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_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("shader.ripple", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_75ripple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_74ripple[] = "\n \n THIS SHADER CREATE A WATER EFFECT ON A PYGAME SURFACE\n This version does not include any background deformation to keep a reasonable FPS rate\n\n * NOTE this shader cannot be apply to the screen directly (screen referencing\n pygame.display.get_surface()),\n\n :param rows_ : integer; Array width\n :param cols_ : integer; Array height\n :param previous_ : numpy.ndarray type (w, h) type float; array use for the transformation\n :param current_ : numpy.ndarray type (w, h) type float; array use for the transformation\n :param array_ : numpy.ndarray type (w, h, 3) type unsigned char\n :return : void\n \n "; static PyObject *__pyx_pw_6shader_75ripple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_rows_; int __pyx_v_cols_; __Pyx_memviewslice __pyx_v_previous_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_current_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ripple (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rows,&__pyx_n_s_cols,&__pyx_n_s_previous,&__pyx_n_s_current,&__pyx_n_s_array,0}; PyObject* values[5] = {0,0,0,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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_rows)) != 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_cols)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("ripple", 1, 5, 5, 1); __PYX_ERR(1, 1305, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_previous)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("ripple", 1, 5, 5, 2); __PYX_ERR(1, 1305, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_current)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("ripple", 1, 5, 5, 3); __PYX_ERR(1, 1305, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_array)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("ripple", 1, 5, 5, 4); __PYX_ERR(1, 1305, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ripple") < 0)) __PYX_ERR(1, 1305, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } __pyx_v_rows_ = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_rows_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1306, __pyx_L3_error) __pyx_v_cols_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_cols_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1307, __pyx_L3_error) __pyx_v_previous_ = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_previous_.memview)) __PYX_ERR(1, 1308, __pyx_L3_error) __pyx_v_current_ = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_current_.memview)) __PYX_ERR(1, 1309, __pyx_L3_error) __pyx_v_array_ = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(values[4], PyBUF_WRITABLE); if (unlikely(!__pyx_v_array_.memview)) __PYX_ERR(1, 1310, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("ripple", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1305, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.ripple", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_74ripple(__pyx_self, __pyx_v_rows_, __pyx_v_cols_, __pyx_v_previous_, __pyx_v_current_, __pyx_v_array_); 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_6shader_74ripple(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_rows_, int __pyx_v_cols_, __Pyx_memviewslice __pyx_v_previous_, __Pyx_memviewslice __pyx_v_current_, __Pyx_memviewslice __pyx_v_array_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ripple", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_previous_.memview)) { __Pyx_RaiseUnboundLocalError("previous_"); __PYX_ERR(1, 1305, __pyx_L1_error) } if (unlikely(!__pyx_v_current_.memview)) { __Pyx_RaiseUnboundLocalError("current_"); __PYX_ERR(1, 1305, __pyx_L1_error) } if (unlikely(!__pyx_v_array_.memview)) { __Pyx_RaiseUnboundLocalError("array_"); __PYX_ERR(1, 1305, __pyx_L1_error) } __pyx_t_1 = __pyx_f_6shader_ripple(__pyx_v_rows_, __pyx_v_cols_, __pyx_v_previous_, __pyx_v_current_, __pyx_v_array_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1305, __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("shader.ripple", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_previous_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_current_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_array_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1306: int rows_,
1307: int cols_,
1308: float [:, ::1] previous_,
1309: float [:, ::1] current_,
1310: unsigned char [:, :, ::1] array_
1311: ):
1312: """
1313:
1314: THIS SHADER CREATE A WATER EFFECT ON A PYGAME SURFACE
1315: This version does not include any background deformation to keep a reasonable FPS rate
1316:
1317: * NOTE this shader cannot be apply to the screen directly (screen referencing
1318: pygame.display.get_surface()),
1319:
1320: :param rows_ : integer; Array width
1321: :param cols_ : integer; Array height
1322: :param previous_ : numpy.ndarray type (w, h) type float; array use for the transformation
1323: :param current_ : numpy.ndarray type (w, h) type float; array use for the transformation
1324: :param array_ : numpy.ndarray type (w, h, 3) type unsigned char
1325: :return : void
1326:
1327: """
+1328: assert PyObject_IsInstance(previous_, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_previous_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_3 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1328, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_4 != 0))) {
+1329: "\nArgument previous must be a numpy.ndarray type got %s " % type(previous_)
__pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_previous_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_previous_must_be_a_num, ((PyObject *)Py_TYPE(__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 1328, __pyx_L1_error) } } #endif
1330:
+1331: assert PyObject_IsInstance(current_, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_current_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_3 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1331, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_4 != 0))) {
+1332: "\nArgument current must be a numpy.ndarray type got %s " % type(current_)
__pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_current_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_current_must_be_a_nump, ((PyObject *)Py_TYPE(__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 1331, __pyx_L1_error) } } #endif
1333:
+1334: assert PyObject_IsInstance(array_, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_3 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 1334, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_4 != 0))) {
+1335: "\nArgument array must be a numpy.ndarray type got %s " % type(array_)
__pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_array_must_be_a_numpy, ((PyObject *)Py_TYPE(__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 1334, __pyx_L1_error) } } #endif
1336:
1337: cdef Py_ssize_t prev_w, prev_h
+1338: prev_w, prev_h = previous_.shape[:2]
__pyx_t_5 = __pyx_v_previous_.shape; __pyx_t_6 = (__pyx_t_5[0]); __pyx_t_7 = (__pyx_t_5[1]); __pyx_v_prev_w = __pyx_t_6; __pyx_v_prev_h = __pyx_t_7;
1339:
1340: cdef Py_ssize_t curr_w, curr_h
+1341: curr_w, curr_h = current_.shape[:2]
__pyx_t_5 = __pyx_v_current_.shape; __pyx_t_7 = (__pyx_t_5[0]); __pyx_t_6 = (__pyx_t_5[1]); __pyx_v_curr_w = __pyx_t_7; __pyx_v_curr_h = __pyx_t_6;
1342:
1343: cdef Py_ssize_t arr_w, arr_h
+1344: arr_w, arr_h = array_.shape[:2]
__pyx_t_5 = __pyx_v_array_.shape; __pyx_t_6 = (__pyx_t_5[0]); __pyx_t_7 = (__pyx_t_5[1]); __pyx_v_arr_w = __pyx_t_6; __pyx_v_arr_h = __pyx_t_7;
1345:
+1346: assert prev_w == curr_w and prev_w == arr_w \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_8 = ((__pyx_v_prev_w == __pyx_v_curr_w) != 0); if (__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L3_bool_binop_done; } /* … */ __pyx_t_8 = ((__pyx_v_prev_w == __pyx_v_arr_w) != 0); if (__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L3_bool_binop_done; }
+1347: and prev_h == curr_h and prev_h == arr_h, \
__pyx_t_8 = ((__pyx_v_prev_h == __pyx_v_curr_h) != 0); if (__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L3_bool_binop_done; } __pyx_t_8 = ((__pyx_v_prev_h == __pyx_v_arr_h) != 0); __pyx_t_4 = __pyx_t_8; __pyx_L3_bool_binop_done:; if (unlikely(!__pyx_t_4)) {
1348: "\n Array sizes mismatch (previous w: %s, h: %s; " \
+1349: "current w: %s, h: %s; array_ w: %s, h: %s " % (prev_w, prev_h, curr_w, curr_h,
__pyx_t_1 = PyInt_FromSsize_t(__pyx_v_prev_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_prev_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_curr_w); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_curr_h); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 1349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); /* … */ __pyx_t_12 = PyTuple_New(6); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 1349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 4, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 5, __pyx_t_11); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyString_Format(__pyx_kp_s_Array_sizes_mismatch_previous_w, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 1349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_11); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(1, 1346, __pyx_L1_error) } } #endif
+1350: arr_w, arr_h)
__pyx_t_10 = PyInt_FromSsize_t(__pyx_v_arr_w); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_arr_h); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 1350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11);
1351:
+1352: return shader_ripple_c(rows_, cols_, previous_, current_, array_)
__Pyx_XDECREF(__pyx_r); __pyx_t_11 = __pyx_f_6shader_shader_ripple_c(__pyx_v_rows_, __pyx_v_cols_, __pyx_v_previous_, __pyx_v_current_, __pyx_v_array_); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 1352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_r = ((PyObject*)__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L0;
1353:
1354:
1355:
1356:
+1357: cpdef inline void heatmap(object surface_, bint rgb_=True):
static PyObject *__pyx_pw_6shader_77heatmap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_heatmap(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_heatmap *__pyx_optional_args) { int __pyx_v_rgb_ = ((int)1); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatmap", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_rgb_ = __pyx_optional_args->rgb_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.heatmap", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_77heatmap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_76heatmap[] = "\n TRANSFORM AN IMAGE INTO A HEATMAP EQUIVALENT\n\n :param surface_ : pygame.Surface\n :param rgb_ : boolean; True transformed the image into a RGB heatmap model of False (BGR)\n :return : void\n "; static PyObject *__pyx_pw_6shader_77heatmap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_rgb_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatmap (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_rgb,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rgb); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "heatmap") < 0)) __PYX_ERR(1, 1357, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_rgb_ = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_rgb_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1357, __pyx_L3_error) } else { __pyx_v_rgb_ = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("heatmap", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1357, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.heatmap", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_76heatmap(__pyx_self, __pyx_v_surface_, __pyx_v_rgb_); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_76heatmap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_rgb_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatmap", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.rgb_ = __pyx_v_rgb_; __pyx_f_6shader_heatmap(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.heatmap", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1358: """
1359: TRANSFORM AN IMAGE INTO A HEATMAP EQUIVALENT
1360:
1361: :param surface_ : pygame.Surface
1362: :param rgb_ : boolean; True transformed the image into a RGB heatmap model of False (BGR)
1363: :return : void
1364: """
+1365: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1365, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1366: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1366, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1365, __pyx_L1_error) } } #endif
1367:
+1368: heatmap_convert(surface_, rgb_)
__pyx_t_4.__pyx_n = 1; __pyx_t_4.rgb_ = __pyx_v_rgb_; __pyx_f_6shader_heatmap_convert(__pyx_v_surface_, 0, &__pyx_t_4);
1369:
1370:
1371:
1372:
1373:
+1374: cpdef inline predator_vision(
static PyObject *__pyx_pw_6shader_79predator_vision(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_predator_vision(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_predator_vision *__pyx_optional_args) { unsigned int __pyx_v_sobel_threshold = ((unsigned int)12); unsigned int __pyx_v_bpf_threshold = ((unsigned int)50); unsigned int __pyx_v_bloom_threshold = ((unsigned int)50); /* … */ /* 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_10); __Pyx_AddTraceback("shader.predator_vision", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_surface_copy); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_79predator_vision(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_78predator_vision[] = "\n CONVERT A SURFACE OR DISPLAY TO AN EQUIVALENT PREDATOR MODE \n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :param sobel_threshold : integer; value for sobel edge detection, default is 12 \n :param bpf_threshold : integer; value for the bright pass filter pixel detection, \n default is 50\n :param bloom_threshold : integer; Value for the bloom effect intensity default is 50\n :param inv_colormap : boolean True | False inverse the colormap aspect, default is False\n :param fast : boolean True | False for a fast process, default is False\n :param blend : boolean True | False; final blending mode (New in version 1.0.4) \n :return : Return a pygame surface \n "; static PyObject *__pyx_pw_6shader_79predator_vision(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; unsigned int __pyx_v_sobel_threshold; unsigned int __pyx_v_bpf_threshold; unsigned int __pyx_v_bloom_threshold; int __pyx_v_inv_colormap; int __pyx_v_fast; int __pyx_v_blend; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("predator_vision (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_sobel_threshold,&__pyx_n_s_bpf_threshold,&__pyx_n_s_bloom_threshold,&__pyx_n_s_inv_colormap,&__pyx_n_s_fast_2,&__pyx_n_s_blend,0}; PyObject* values[7] = {0,0,0,0,0,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 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_surface)) != 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_sobel_threshold); 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_bpf_threshold); 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_bloom_threshold); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_inv_colormap); if (value) { values[4] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fast_2); if (value) { values[5] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_blend); if (value) { values[6] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "predator_vision") < 0)) __PYX_ERR(1, 1374, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_surface_ = values[0]; if (values[1]) { __pyx_v_sobel_threshold = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_sobel_threshold == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1376, __pyx_L3_error) } else { __pyx_v_sobel_threshold = ((unsigned int)12); } if (values[2]) { __pyx_v_bpf_threshold = __Pyx_PyInt_As_unsigned_int(values[2]); if (unlikely((__pyx_v_bpf_threshold == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1377, __pyx_L3_error) } else { __pyx_v_bpf_threshold = ((unsigned int)50); } if (values[3]) { __pyx_v_bloom_threshold = __Pyx_PyInt_As_unsigned_int(values[3]); if (unlikely((__pyx_v_bloom_threshold == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1378, __pyx_L3_error) } else { __pyx_v_bloom_threshold = ((unsigned int)50); } if (values[4]) { __pyx_v_inv_colormap = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_inv_colormap == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1379, __pyx_L3_error) } else { /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_78predator_vision(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, unsigned int __pyx_v_sobel_threshold, unsigned int __pyx_v_bpf_threshold, unsigned int __pyx_v_bloom_threshold, int __pyx_v_inv_colormap, int __pyx_v_fast, int __pyx_v_blend) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("predator_vision", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 6; __pyx_t_2.sobel_threshold = __pyx_v_sobel_threshold; __pyx_t_2.bpf_threshold = __pyx_v_bpf_threshold; __pyx_t_2.bloom_threshold = __pyx_v_bloom_threshold; __pyx_t_2.inv_colormap = __pyx_v_inv_colormap; __pyx_t_2.fast = __pyx_v_fast; __pyx_t_2.blend = __pyx_v_blend; __pyx_t_1 = __pyx_f_6shader_predator_vision(__pyx_v_surface_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1374, __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("shader.predator_vision", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1375: object surface_,
1376: unsigned int sobel_threshold=12,
1377: unsigned int bpf_threshold=50,
1378: unsigned int bloom_threshold=50,
+1379: bint inv_colormap=False,
int __pyx_v_inv_colormap = ((int)0); /* … */ __pyx_v_inv_colormap = ((int)0); } if (values[5]) { __pyx_v_fast = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_fast == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1380, __pyx_L3_error) } else {
+1380: bint fast=False,
int __pyx_v_fast = ((int)0); int __pyx_v_blend = __pyx_k__11; PyObject *__pyx_v_surface_copy = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("predator_vision", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_sobel_threshold = __pyx_optional_args->sobel_threshold; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_bpf_threshold = __pyx_optional_args->bpf_threshold; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_bloom_threshold = __pyx_optional_args->bloom_threshold; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_inv_colormap = __pyx_optional_args->inv_colormap; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_fast = __pyx_optional_args->fast; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_blend = __pyx_optional_args->blend; } } } } } } } /* … */ __pyx_v_fast = ((int)0); } if (values[6]) { __pyx_v_blend = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_blend == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1381, __pyx_L3_error) } else { __pyx_v_blend = __pyx_k__11; } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("predator_vision", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1374, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.predator_vision", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_78predator_vision(__pyx_self, __pyx_v_surface_, __pyx_v_sobel_threshold, __pyx_v_bpf_threshold, __pyx_v_bloom_threshold, __pyx_v_inv_colormap, __pyx_v_fast, __pyx_v_blend);
+1381: int blend=pygame.BLEND_RGB_ADD
__Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_pygame); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 1381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 1381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_30); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1381, __pyx_L1_error) __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __pyx_k__11 = __pyx_t_7; /* … */ __Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_n_s_pygame); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 1381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); /* … */ __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 1381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_33); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1381, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __pyx_k__11 = __pyx_t_7;
1382: ):
1383: """
1384: CONVERT A SURFACE OR DISPLAY TO AN EQUIVALENT PREDATOR MODE
1385:
1386: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1387: :param sobel_threshold : integer; value for sobel edge detection, default is 12
1388: :param bpf_threshold : integer; value for the bright pass filter pixel detection,
1389: default is 50
1390: :param bloom_threshold : integer; Value for the bloom effect intensity default is 50
1391: :param inv_colormap : boolean True | False inverse the colormap aspect, default is False
1392: :param fast : boolean True | False for a fast process, default is False
1393: :param blend : boolean True | False; final blending mode (New in version 1.0.4)
1394: :return : Return a pygame surface
1395: """
1396:
+1397: surface_copy = surface_.copy()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 1397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_surface_copy = __pyx_t_1; __pyx_t_1 = 0;
1398:
+1399: if fast:
__pyx_t_4 = (__pyx_v_fast != 0); if (__pyx_t_4) { /* … */ goto __pyx_L3; }
+1400: sobel_fast(surface_copy, sobel_threshold, factor_=1)
__pyx_t_5.__pyx_n = 2; __pyx_t_5.threshold_ = __pyx_v_sobel_threshold; __pyx_t_5.factor_ = 1; __pyx_f_6shader_sobel_fast(__pyx_v_surface_copy, 0, &__pyx_t_5);
1401: else:
+1402: sobel(surface_copy, sobel_threshold)
/*else*/ { __pyx_t_6.__pyx_n = 1; __pyx_t_6.threshold_ = __pyx_v_sobel_threshold; __pyx_f_6shader_sobel(__pyx_v_surface_copy, 0, &__pyx_t_6); } __pyx_L3:;
1403:
+1404: bpf(surface_, bpf_threshold)
__pyx_t_7.__pyx_n = 1; __pyx_t_7.threshold = __pyx_v_bpf_threshold; __pyx_f_6shader_bpf(__pyx_v_surface_, 0, &__pyx_t_7);
+1405: shader_bloom_effect_array24_c(surface_, bloom_threshold, fast_=True)
__pyx_t_8.__pyx_n = 1; __pyx_t_8.fast_ = 1; __pyx_f_6shader_shader_bloom_effect_array24_c(__pyx_v_surface_, __pyx_v_bloom_threshold, &__pyx_t_8);
+1406: heatmap_convert(surface_, inv_colormap)
__pyx_t_9.__pyx_n = 1; __pyx_t_9.rgb_ = __pyx_v_inv_colormap; __pyx_f_6shader_heatmap_convert(__pyx_v_surface_, 0, &__pyx_t_9);
+1407: surface_.blit(surface_copy, (0, 0), special_flags=blend)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_surface_copy); __Pyx_GIVEREF(__pyx_v_surface_copy); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_surface_copy); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_tuple__12); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_blend); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_special_flags, __pyx_t_10) < 0) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* … */ __pyx_tuple__12 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12);
1408:
+1409: return surface_.convert()
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_convert); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_10 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 1409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0;
1410:
1411:
1412:
1413:
+1414: cpdef inline blood(object surface_, float [:, :] mask_, float perc_):
static PyObject *__pyx_pw_6shader_81blood(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_blood(PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_mask_, float __pyx_v_perc_, CYTHON_UNUSED int __pyx_skip_dispatch) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; Py_ssize_t __pyx_v_mask_w; Py_ssize_t __pyx_v_mask_h; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blood", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_AddTraceback("shader.blood", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_81blood(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_80blood[] = "\n SHADER 2D GAME \"HURT EFFECT\"\n \n This effect is used in 2D game when the player is being hurt\n THE MASK DETERMINE THE CONTOUR USED FOR THE BLOOD EFFECT.\n\n :param surface_ : pygame.Surface; compatible surface 24 - 32 bit\n :param mask_ : numpy.ndarray shape (w, h) of float values in range [0.0...1.0]\n :param perc_ : Percentage value in range [0.0 ... 1.0] with 1.0 being 100%\n :return : void\n \n "; static PyObject *__pyx_pw_6shader_81blood(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; __Pyx_memviewslice __pyx_v_mask_ = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_perc_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blood (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_mask_2,&__pyx_n_s_perc,0}; PyObject* values[3] = {0,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 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_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_mask_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("blood", 1, 3, 3, 1); __PYX_ERR(1, 1414, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_perc)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("blood", 1, 3, 3, 2); __PYX_ERR(1, 1414, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blood") < 0)) __PYX_ERR(1, 1414, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_surface_ = values[0]; __pyx_v_mask_ = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_mask_.memview)) __PYX_ERR(1, 1414, __pyx_L3_error) __pyx_v_perc_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_perc_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1414, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("blood", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1414, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.blood", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_80blood(__pyx_self, __pyx_v_surface_, __pyx_v_mask_, __pyx_v_perc_); 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_6shader_80blood(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, __Pyx_memviewslice __pyx_v_mask_, float __pyx_v_perc_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blood", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_mask_.memview)) { __Pyx_RaiseUnboundLocalError("mask_"); __PYX_ERR(1, 1414, __pyx_L1_error) } __pyx_t_1 = __pyx_f_6shader_blood(__pyx_v_surface_, __pyx_v_mask_, __pyx_v_perc_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1414, __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("shader.blood", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_mask_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1415: """
1416: SHADER 2D GAME "HURT EFFECT"
1417:
1418: This effect is used in 2D game when the player is being hurt
1419: THE MASK DETERMINE THE CONTOUR USED FOR THE BLOOD EFFECT.
1420:
1421: :param surface_ : pygame.Surface; compatible surface 24 - 32 bit
1422: :param mask_ : numpy.ndarray shape (w, h) of float values in range [0.0...1.0]
1423: :param perc_ : Percentage value in range [0.0 ... 1.0] with 1.0 being 100%
1424: :return : void
1425:
1426: """
+1427: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1427, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1427, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1428: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1427, __pyx_L1_error) } } #endif
1429:
+1430: assert PyObject_IsInstance(mask_, (numpy.ndarray, cython.view.memoryview)), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_mask_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_memoryview_type)); __Pyx_GIVEREF(((PyObject *)__pyx_memoryview_type)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_memoryview_type)); __pyx_t_4 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1430, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1431: "\nArgument mask_ must be a numpy.ndarray or cython memoryview types got %s " % type(mask_)
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_mask_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_mask__must_be_a_numpy, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1430, __pyx_L1_error) } } #endif
1432:
1433: cdef Py_ssize_t w, h
+1434: w, h = surface_.get_size()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; 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(1, 1434, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(1, 1434, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 1434, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1434, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_w = __pyx_t_7; __pyx_v_h = __pyx_t_8;
1435:
1436: cdef Py_ssize_t mask_w, mask_h
+1437: mask_w, mask_h = mask_.shape[:2]
__pyx_t_9 = __pyx_v_mask_.shape; __pyx_t_8 = (__pyx_t_9[0]); __pyx_t_7 = (__pyx_t_9[1]); __pyx_v_mask_w = __pyx_t_8; __pyx_v_mask_h = __pyx_t_7;
1438:
+1439: assert w == mask_w and h == mask_h, "\nSurface size and mask size mismatch"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_10 = ((__pyx_v_w == __pyx_v_mask_w) != 0); if (__pyx_t_10) { } else { __pyx_t_3 = __pyx_t_10; goto __pyx_L5_bool_binop_done; } __pyx_t_10 = ((__pyx_v_h == __pyx_v_mask_h) != 0); __pyx_t_3 = __pyx_t_10; __pyx_L5_bool_binop_done:; if (unlikely(!__pyx_t_3)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Surface_size_and_mask_size_mism); __PYX_ERR(1, 1439, __pyx_L1_error) } } #endif
1440:
+1441: shader_blood_inplace_c(pixels3d(surface_), mask_, perc_)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1441, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 1441, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_blood_inplace_c(__pyx_t_11, __pyx_v_mask_, __pyx_v_perc_); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
1442:
1443:
1444: # TODO DOC
+1445: cpdef inline object make_palette(int width, float fh, float fs, float fl):
static PyObject *__pyx_pw_6shader_83make_palette(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_make_palette(int __pyx_v_width, float __pyx_v_fh, float __pyx_v_fs, float __pyx_v_fl, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_palette", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("shader.make_palette", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_83make_palette(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_82make_palette[] = "\n \n CREATE A PALETTE OF RGB COLORS\n\n e.g:\n # below: palette of 256 colors & surface (width=256, height=50).\n # hue * 6, saturation = 255.0, lightness * 2.0\n palette, surf = make_palette(256, 50, 6, 255, 2)\n palette, surf = make_palette(256, 50, 4, 255, 2)\n\n :param width : integer, Palette width\n :param fh : float, hue factor\n :param fs : float, saturation factor\n :param fl : float, lightness factor\n :return : Return a 1D array palette\n\n "; static PyObject *__pyx_pw_6shader_83make_palette(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_width; float __pyx_v_fh; float __pyx_v_fs; float __pyx_v_fl; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_palette (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width,&__pyx_n_s_fh,&__pyx_n_s_fs,&__pyx_n_s_fl,0}; PyObject* values[4] = {0,0,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 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_fh)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("make_palette", 1, 4, 4, 1); __PYX_ERR(1, 1445, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fs)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("make_palette", 1, 4, 4, 2); __PYX_ERR(1, 1445, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fl)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("make_palette", 1, 4, 4, 3); __PYX_ERR(1, 1445, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "make_palette") < 0)) __PYX_ERR(1, 1445, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_width = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1445, __pyx_L3_error) __pyx_v_fh = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_fh == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1445, __pyx_L3_error) __pyx_v_fs = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_fs == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1445, __pyx_L3_error) __pyx_v_fl = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_fl == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1445, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("make_palette", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1445, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.make_palette", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_82make_palette(__pyx_self, __pyx_v_width, __pyx_v_fh, __pyx_v_fs, __pyx_v_fl); 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_6shader_82make_palette(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_width, float __pyx_v_fh, float __pyx_v_fs, float __pyx_v_fl) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_palette", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_make_palette(__pyx_v_width, __pyx_v_fh, __pyx_v_fs, __pyx_v_fl, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1445, __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("shader.make_palette", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1446: """
1447:
1448: CREATE A PALETTE OF RGB COLORS
1449:
1450: e.g:
1451: # below: palette of 256 colors & surface (width=256, height=50).
1452: # hue * 6, saturation = 255.0, lightness * 2.0
1453: palette, surf = make_palette(256, 50, 6, 255, 2)
1454: palette, surf = make_palette(256, 50, 4, 255, 2)
1455:
1456: :param width : integer, Palette width
1457: :param fh : float, hue factor
1458: :param fs : float, saturation factor
1459: :param fl : float, lightness factor
1460: :return : Return a 1D array palette
1461:
1462: """
1463:
+1464: return make_palette_c(width, fh, fs, fl)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_make_palette_c(__pyx_v_width, __pyx_v_fh, __pyx_v_fs, __pyx_v_fl); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1465:
1466:
1467: # todo develop DOC
+1468: cpdef inline fire_sub(
static PyObject *__pyx_pw_6shader_85fire_sub(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_fire_sub(int __pyx_v_width, int __pyx_v_height, float __pyx_v_factor, __Pyx_memviewslice __pyx_v_palette, __Pyx_memviewslice __pyx_v_fire, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_sub", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("shader.fire_sub", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_85fire_sub(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_84fire_sub[] = "\n\n CREATE A FIRE EFFECT\n\n :param width : integer; max width of the effect\n :param height : integer; max height of the effect\n :param factor : float; factor to reduce the flame effect\n :param palette : ndarray; Color palette 1d numpy array (colors buffer unsigned int values)\n :param fire : ndarray; 2d array (x, y) (contiguous) containing float values\n :return : Return a numpy array containing the fire effect array shape\n (w, h, 3) of RGB pixels\n \n "; static PyObject *__pyx_pw_6shader_85fire_sub(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_width; int __pyx_v_height; float __pyx_v_factor; __Pyx_memviewslice __pyx_v_palette = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_fire = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_sub (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_factor_2,&__pyx_n_s_palette_2,&__pyx_n_s_fire,0}; PyObject* values[5] = {0,0,0,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 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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("fire_sub", 1, 5, 5, 1); __PYX_ERR(1, 1468, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_sub", 1, 5, 5, 2); __PYX_ERR(1, 1468, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_palette_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_sub", 1, 5, 5, 3); __PYX_ERR(1, 1468, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fire)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_sub", 1, 5, 5, 4); __PYX_ERR(1, 1468, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fire_sub") < 0)) __PYX_ERR(1, 1468, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 5) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); } __pyx_v_width = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1469, __pyx_L3_error) __pyx_v_height = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1470, __pyx_L3_error) __pyx_v_factor = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_factor == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1471, __pyx_L3_error) __pyx_v_palette = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_int(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_palette.memview)) __PYX_ERR(1, 1472, __pyx_L3_error) __pyx_v_fire = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(values[4], PyBUF_WRITABLE); if (unlikely(!__pyx_v_fire.memview)) __PYX_ERR(1, 1473, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fire_sub", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1468, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.fire_sub", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_84fire_sub(__pyx_self, __pyx_v_width, __pyx_v_height, __pyx_v_factor, __pyx_v_palette, __pyx_v_fire); 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_6shader_84fire_sub(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_width, int __pyx_v_height, float __pyx_v_factor, __Pyx_memviewslice __pyx_v_palette, __Pyx_memviewslice __pyx_v_fire) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_sub", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_palette.memview)) { __Pyx_RaiseUnboundLocalError("palette"); __PYX_ERR(1, 1468, __pyx_L1_error) } if (unlikely(!__pyx_v_fire.memview)) { __Pyx_RaiseUnboundLocalError("fire"); __PYX_ERR(1, 1468, __pyx_L1_error) } __pyx_t_1 = __pyx_f_6shader_fire_sub(__pyx_v_width, __pyx_v_height, __pyx_v_factor, __pyx_v_palette, __pyx_v_fire, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1468, __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("shader.fire_sub", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_palette, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_fire, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1469: int width,
1470: int height,
1471: float factor,
1472: unsigned int [::1] palette,
1473: float [:, ::1] fire
1474: ):
1475: """
1476:
1477: CREATE A FIRE EFFECT
1478:
1479: :param width : integer; max width of the effect
1480: :param height : integer; max height of the effect
1481: :param factor : float; factor to reduce the flame effect
1482: :param palette : ndarray; Color palette 1d numpy array (colors buffer unsigned int values)
1483: :param fire : ndarray; 2d array (x, y) (contiguous) containing float values
1484: :return : Return a numpy array containing the fire effect array shape
1485: (w, h, 3) of RGB pixels
1486:
1487: """
1488:
+1489: return fire_surface24_c(width, height, factor, palette, fire)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_fire_surface24_c(__pyx_v_width, __pyx_v_height, __pyx_v_factor, __pyx_v_palette, __pyx_v_fire, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1490:
1491:
1492:
1493:
+1494: cpdef inline fire_effect(
static PyObject *__pyx_pw_6shader_87fire_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_fire_effect(int __pyx_v_width_, int __pyx_v_height_, float __pyx_v_factor_, __Pyx_memviewslice __pyx_v_palette_, __Pyx_memviewslice __pyx_v_fire_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_fire_effect *__pyx_optional_args) { unsigned short __pyx_v_reduce_factor_ = ((unsigned short)3); unsigned short __pyx_v_fire_intensity_ = ((unsigned short)32); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("shader.fire_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_87fire_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_86fire_effect[] = "\n FIRE SHADER EFFECT \n\n * FIRE TEXTURE SIZES \n \n input width_ : integer, \n input height_ : integer\n \n width_ and height_ values define the size of the texture e.g Surface(width x height)\n\n * FIRE ASPECT (CONTROL OVER THE WIDTH): \n \n inputs low_ : integer \n input high_ : integer \n \n Optional arguments low_ & high_ (integer values) define the width 's limits of the fire effect. \n low_ for the starting point and high_ for the ending of the effect.\n e.g low_ = 10 and high_ = 200. The fire effect will be contain within width = 10 and 200\n low_ & high_ values must be in range [0 ... width_] \n \n * FIRE HEIGHT:\n \n input factor_ : float\n \n The fire maximum height can be adjust with the variable factor_ (float value)\n value > 3.95 will contain the effect within the display \n value < 3.95 will enlarge the effect over the display height \n Recommended value is 3.95 with reduce_factor_ = 3 otherwise adjust the value manually \n to contain the fire effect within the display\n \n * SPEED CONSIDERATION\n \n input reduce_factor_ : integer\n \n The argument reduce_factor_ control the size of the texture to be processed \n e.g : a value of 2, divide by 4 the pygame surface define by the values (width_ & height_)\n Smaller texture improve the overall performances but will slightly degrade the fire aspect, \n especially if the blur and smooth option are not enabled.\n Recommended value for reduce_factor_ is 3 (fast process) \n reduce_factor_ values must be an integer in range [ 0 ... 4] \n The reduce_factor_ value will have a significant impact on the fire effect maximum height, \n adjust the argument factor_ accordingly\n\n * FIRE INTENSITY AT THE SOURCE\n \n input fire_intensity_: integer\n \n Set the fire intensity with the variable fire_intensity_, 0 low flame,\n 32 maximum flame effect\n Values must be an ""int in range [0 ... 32] \n\n * SMOOTHING THE EFFECT\n \n input smooth_: True | False\n \n When smooth_ is True the algorithm will use the pygame function smoothscale (bi-linear \n filtering) or False the final texture will be adjust with the scale function.\n Set this variable to False if you need the best performance for the effect or if you require\n a pixelated fire effect. Otherwise set the variable to True for a more realistic effect. \n\n \n * BLOOM EFFECT \n \n input bloom_ : True | False\n input fast_bloom_ : True | False\n input bpf_threshold_ : integer\n \n Fire effect produce a bright and smooth light effect to the background texture where the fire \n intensity is at its maximum.\n Use the flag fast_bloom_ for a compromise between a realistic effect and the best performances\n The flag fast_bloom_ define a very fast bloom algo using only the smallest texture \n to create a bloom effect (all the intermediate textures will be bypassed). See the bloom effect \n project for more details.\n When fast_bloom is False, all the sub-surfaces will be blit to the final effect and will \n produce a more realistic fire effect (this will slightly degrade the overall performances). \n If the fire effect is too bright, you can always adjust the bright pass filter value\n bpf_threshold_(this will adjust the bloom intensity)\n bpf_threshold_ value must be in range [ 0 ... 255] \n Below 128 the bloom effect will be more noticeable and above 128 only the brightest\n area will be enhanced.\n\n * LIGHT EFFECT INTENSITY\n\n input brightness_ : True | False\n input brightness_intensity_ : float\n\n When the flag is set to True, the algorithm will use an external function, \n <shader_brightness24_exclude_inplace_c> to increase the brightness of the effect / texture\n A custom color can be passed to the function defining the pixels to be ignored during t""he \n process (default is black color).\n the value must be in range [-1.0 ... 1.0]. Values below zero will decrease the brightness \n of the flame effect and positive values will increase the brightness of the effect (causing\n bright white patches on the fire texture). \n Values below -0.4 will cause the fire effect to be translucent and this effect can also be \n used for simulating ascending heat convection effects on a background texture.\n \n \n * OPTIONAL SURFACE\n \n input surface_ : pygame.Surface\n \n This is an optional surface that can be passed to the shader to improve the performances \n and to avoid a new surface to be generated every iterations. The surface size must match \n exactly the reduce texture dimensions otherwise an exception will be raise. \n see reduce_factor_ option to determine the fire texture size that will be processed.\n \n * COLOR PALETTE ADJUSTMENT \n \n input adjust_palette_ : True | False\n input hsl_ : (10, 80, 1.8)\n\n Set this flag to True to modify the color palette of the fire texture. \n This allow the HSL color model to be apply to the palette values\n You can redefine the palette when the flag is True and by customizing a tuple of 3 float \n values, default is (10, 80, 1.8). \n The first value control the palette hue value, the second is for the saturation and last, \n the palette color lightness. \n With the variable hsl_ you can rotate the palette colors and define a new flame\n aspect/color/intensity\n If adjust_palette_ is True the original palette define by the argument palette_, will \n be disregarded.Instead a new palette will be created with the hsl values\n\n * FLAME ORIENTATION / DIRECTION & BORDER FLAME EFFECT\n \n input transpose_ = True | False,\n input border_ = True | False,\n \n transpose_ = True, this will transpose the final array \n for e.g : \n If the final fire tex""ture is (w, h) after setting the transpose flag, the final \n fire texture will become (h, w). As a result the fire effect will be transversal (starting \n from the right of the display to the left side). \n You can always transpose / flip the texture to get the right flame orientation \n BORDER FLAME EFFECT \n border_ = True to create a flame effect burning the edge of the display. This version is only\n compatible with symmetrical display or textures (same width & height). If the display \n is asymmetric, the final border fire effect will be shown within the display and not neccessary \n on the frame border \n \n * FINAL TOUCH\n \n input blur_ : True | False\n \n This will will blur the fire effect for a more realistic appearance, remove all the jagged \n edge when and pixelated effect\n \n \n :param width_ : integer; Size (width) of the surface or display in pixels\n :param height_ : integer; size (height) of the surface or display in pixels\n :param factor_ : float; Value controlling the fire height value\n must be in range [3.95 ... 4.2].\n The value 3.95 gives the highest flame effect\n :param palette_ : numpy.ndarray, buffer containing mapped RGB colors (uint values)\n :param fire_ : numpy.ndarray shape (w, h) containing float values (fire intensity).\n For better performance it is advised to set the array to the size \n of the texture after applying the reduction_factor_.\n For example if the reduction_factor_ is 2, the texture would have \n width >> 1 and height >> 1 and the fire_array should be set to \n numpy.empty((height >> 1, width >> 1), float32)\n :param reduce_factor_ : unsigned short int ; Can be either 0, 1, 2, 3, 4. \n "" 2 and 3 provide the best performance and the best looking effect.\n :param fire_intensity_ : Integer; Control the original amount of energy at the\n bottom of the fire, must be in range of [0 ... 32]. \n 32 being the maximum value and the maximum fire intensity\n :param smooth_ : boolean; True smoothscale (bi-linear filtering) or\n scale algorithm jagged edges (mush faster)\n :param bloom_ : boolean; True or False, True apply a bloom effect to the fire effect\n :param fast_bloom_ : boolean; Fastest bloom. This reduce the amount of calculation\n :param bpf_threshold_ : integer; control the bright pass filter threshold\n value, must be in range [0 ... 255].\n Maximum brightness amplification with threshold = 0, \n when bpf_threshold_ = 255, no change.\n :param low_ : integer; Starting position x for the fire effect\n :param high_ : integer; Ending position x for the fire effect\n :param brightness_ : boolean; True apply a bright filter shader to the array.\n Increase overall brightness of the effect\n :param brightness_intensity_: float; must be in range [-1.0 ... 1.0] control\n the brightness intensity\n of the effect\n :param surface_ : pygame.Surface. Pass a surface to the shader for\n better performance, otherwise a new surface will be created each \n calls.\n :param adjust_palette_ : boolean; True adjust the palette setting HSL\n (hue, saturation, luminescence).\n Be aware that if adjust_palette is True, the optional palette \n passed to the Shader wil""l be disregarded\n :param hsl_ : tuple; float values of hue, saturation and luminescence.\n Hue in range [0.0 ... 100], saturation [0...100], \n luminescence [0.0 ... 2.0]\n :param transpose_ : boolean; Transpose the array (w, h) become (h, w).\n The fire effect will start from the left and move to the right\n :param border_ : boolean; Flame effect affect the border of the texture\n :param blur_ : boolean; Blur the fire effect\n :return : Return a pygame surface that can be blit directly to the game display\n\n "; static PyObject *__pyx_pw_6shader_87fire_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_width_; int __pyx_v_height_; float __pyx_v_factor_; __Pyx_memviewslice __pyx_v_palette_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_fire_ = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned short __pyx_v_reduce_factor_; unsigned short __pyx_v_fire_intensity_; int __pyx_v_smooth_; int __pyx_v_bloom_; int __pyx_v_fast_bloom_; unsigned char __pyx_v_bpf_threshold_; unsigned int __pyx_v_low_; unsigned int __pyx_v_high_; int __pyx_v_brightness_; float __pyx_v_brightness_intensity_; PyObject *__pyx_v_surface_ = 0; int __pyx_v_adjust_palette_; PyObject *__pyx_v_hsl_ = 0; int __pyx_v_transpose_; int __pyx_v_border_; int __pyx_v_blur_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_effect (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width_2,&__pyx_n_s_height_2,&__pyx_n_s_factor,&__pyx_n_s_palette,&__pyx_n_s_fire_2,&__pyx_n_s_reduce_factor,&__pyx_n_s_fire_intensity,&__pyx_n_s_smooth,&__pyx_n_s_bloom,&__pyx_n_s_fast_bloom,&__pyx_n_s_bpf_threshold_2,&__pyx_n_s_low,&__pyx_n_s_high,&__pyx_n_s_brightness,&__pyx_n_s_brightness_intensity,&__pyx_n_s_surface,&__pyx_n_s_adjust_palette,&__pyx_n_s_hsl,&__pyx_n_s_transpose,&__pyx_n_s_border,&__pyx_n_s_blur,0}; PyObject* values[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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_6shader_86fire_effect(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_width_, int __pyx_v_height_, float __pyx_v_factor_, __Pyx_memviewslice __pyx_v_palette_, __Pyx_memviewslice __pyx_v_fire_, unsigned short __pyx_v_reduce_factor_, unsigned short __pyx_v_fire_intensity_, int __pyx_v_smooth_, int __pyx_v_bloom_, int __pyx_v_fast_bloom_, unsigned char __pyx_v_bpf_threshold_, unsigned int __pyx_v_low_, unsigned int __pyx_v_high_, int __pyx_v_brightness_, float __pyx_v_brightness_intensity_, PyObject *__pyx_v_surface_, int __pyx_v_adjust_palette_, PyObject *__pyx_v_hsl_, int __pyx_v_transpose_, int __pyx_v_border_, int __pyx_v_blur_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_effect", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_palette_.memview)) { __Pyx_RaiseUnboundLocalError("palette_"); __PYX_ERR(1, 1494, __pyx_L1_error) } if (unlikely(!__pyx_v_fire_.memview)) { __Pyx_RaiseUnboundLocalError("fire_"); __PYX_ERR(1, 1494, __pyx_L1_error) } __pyx_t_2.__pyx_n = 16; __pyx_t_2.reduce_factor_ = __pyx_v_reduce_factor_; __pyx_t_2.fire_intensity_ = __pyx_v_fire_intensity_; __pyx_t_2.smooth_ = __pyx_v_smooth_; __pyx_t_2.bloom_ = __pyx_v_bloom_; __pyx_t_2.fast_bloom_ = __pyx_v_fast_bloom_; __pyx_t_2.bpf_threshold_ = __pyx_v_bpf_threshold_; __pyx_t_2.low_ = __pyx_v_low_; __pyx_t_2.high_ = __pyx_v_high_; __pyx_t_2.brightness_ = __pyx_v_brightness_; __pyx_t_2.brightness_intensity_ = __pyx_v_brightness_intensity_; __pyx_t_2.surface_ = __pyx_v_surface_; __pyx_t_2.adjust_palette_ = __pyx_v_adjust_palette_; __pyx_t_2.hsl_ = __pyx_v_hsl_; __pyx_t_2.transpose_ = __pyx_v_transpose_; __pyx_t_2.border_ = __pyx_v_border_; __pyx_t_2.blur_ = __pyx_v_blur_; __pyx_t_1 = __pyx_f_6shader_fire_effect(__pyx_v_width_, __pyx_v_height_, __pyx_v_factor_, __pyx_v_palette_, __pyx_v_fire_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1494, __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("shader.fire_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_palette_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_fire_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1495: int width_,
1496: int height_,
1497: float factor_,
1498: unsigned int [::1] palette_,
1499: float [:, ::1] fire_,
1500:
1501: # OPTIONAL
1502: unsigned short int reduce_factor_ = 3,
1503: unsigned short int fire_intensity_= 32,
+1504: bint smooth_ = True,
int __pyx_v_smooth_ = ((int)1); /* … */ __pyx_v_smooth_ = ((int)1); } if (values[8]) { __pyx_v_bloom_ = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_bloom_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1505, __pyx_L3_error) } else {
+1505: bint bloom_ = True,
int __pyx_v_bloom_ = ((int)1); /* … */ __pyx_v_bloom_ = ((int)1); } if (values[9]) { __pyx_v_fast_bloom_ = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_fast_bloom_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1506, __pyx_L3_error) } else {
+1506: bint fast_bloom_ = True,
int __pyx_v_fast_bloom_ = ((int)1); unsigned char __pyx_v_bpf_threshold_ = ((unsigned char)0); unsigned int __pyx_v_low_ = ((unsigned int)0); unsigned int __pyx_v_high_ = ((unsigned int)0x258); /* … */ __pyx_v_fast_bloom_ = ((int)1); } if (values[10]) { __pyx_v_bpf_threshold_ = __Pyx_PyInt_As_unsigned_char(values[10]); if (unlikely((__pyx_v_bpf_threshold_ == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 1507, __pyx_L3_error) } else { __pyx_v_bpf_threshold_ = ((unsigned char)0); } if (values[11]) { __pyx_v_low_ = __Pyx_PyInt_As_unsigned_int(values[11]); if (unlikely((__pyx_v_low_ == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1508, __pyx_L3_error) } else { __pyx_v_low_ = ((unsigned int)0); } if (values[12]) { __pyx_v_high_ = __Pyx_PyInt_As_unsigned_int(values[12]); if (unlikely((__pyx_v_high_ == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1509, __pyx_L3_error) } else { __pyx_v_high_ = ((unsigned int)0x258); } if (values[13]) { __pyx_v_brightness_ = __Pyx_PyObject_IsTrue(values[13]); if (unlikely((__pyx_v_brightness_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1510, __pyx_L3_error) } else {
1507: unsigned char bpf_threshold_ = 0,
1508: unsigned int low_ = 0,
1509: unsigned int high_ = 600,
+1510: bint brightness_ = True,
int __pyx_v_brightness_ = ((int)1); float __pyx_v_brightness_intensity_ = ((float)0.15); /* … */ __pyx_v_brightness_ = ((int)1); } if (values[14]) { __pyx_v_brightness_intensity_ = __pyx_PyFloat_AsFloat(values[14]); if (unlikely((__pyx_v_brightness_intensity_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1511, __pyx_L3_error) } else { __pyx_v_brightness_intensity_ = ((float)0.15); } __pyx_v_surface_ = values[15]; if (values[16]) { __pyx_v_adjust_palette_ = __Pyx_PyObject_IsTrue(values[16]); if (unlikely((__pyx_v_adjust_palette_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1513, __pyx_L3_error) } else {
1511: float brightness_intensity_ = 0.15,
+1512: object surface_ = None,
PyObject *__pyx_v_surface_ = ((PyObject *)Py_None); /* … */ values[15] = ((PyObject *)Py_None);
+1513: bint adjust_palette_ = False,
int __pyx_v_adjust_palette_ = ((int)0); /* … */ __pyx_v_adjust_palette_ = ((int)0); } __pyx_v_hsl_ = ((PyObject*)values[17]); if (values[18]) { __pyx_v_transpose_ = __Pyx_PyObject_IsTrue(values[18]); if (unlikely((__pyx_v_transpose_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1515, __pyx_L3_error) } else {
+1514: tuple hsl_ = (10, 80, 1.8),
PyObject *__pyx_v_hsl_ = ((PyObject*)__pyx_tuple__13); /* … */ __pyx_tuple__13 = PyTuple_Pack(3, __pyx_int_10, __pyx_int_80, __pyx_float_1_8); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 1514, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); /* … */ values[17] = ((PyObject*)__pyx_tuple__14); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 21: values[20] = PyTuple_GET_ITEM(__pyx_args, 20); CYTHON_FALLTHROUGH; case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19); CYTHON_FALLTHROUGH; case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18); CYTHON_FALLTHROUGH; case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); CYTHON_FALLTHROUGH; case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); CYTHON_FALLTHROUGH; case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); CYTHON_FALLTHROUGH; case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_2)) != 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_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_effect", 0, 5, 21, 1); __PYX_ERR(1, 1494, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_effect", 0, 5, 21, 2); __PYX_ERR(1, 1494, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_palette)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_effect", 0, 5, 21, 3); __PYX_ERR(1, 1494, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fire_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("fire_effect", 0, 5, 21, 4); __PYX_ERR(1, 1494, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_factor); if (value) { values[5] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fire_intensity); if (value) { values[6] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_smooth); if (value) { values[7] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bloom); if (value) { values[8] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fast_bloom); if (value) { values[9] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bpf_threshold_2); if (value) { values[10] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_low); if (value) { values[11] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_high); if (value) { values[12] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 13: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_brightness); if (value) { values[13] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 14: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_brightness_intensity); if (value) { values[14] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 15: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_surface); if (value) { values[15] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 16: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_adjust_palette); if (value) { values[16] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 17: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_hsl); if (value) { values[17] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 18: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transpose); if (value) { values[18] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 19: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_border); if (value) { values[19] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 20: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_blur); if (value) { values[20] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fire_effect") < 0)) __PYX_ERR(1, 1494, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 21: values[20] = PyTuple_GET_ITEM(__pyx_args, 20); CYTHON_FALLTHROUGH; case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19); CYTHON_FALLTHROUGH; case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18); CYTHON_FALLTHROUGH; case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); CYTHON_FALLTHROUGH; case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); CYTHON_FALLTHROUGH; case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); CYTHON_FALLTHROUGH; case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[2] = PyTuple_GET_ITEM(__pyx_args, 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(1, 1495, __pyx_L3_error) __pyx_v_height_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1496, __pyx_L3_error) __pyx_v_factor_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_factor_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1497, __pyx_L3_error) __pyx_v_palette_ = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_int(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_palette_.memview)) __PYX_ERR(1, 1498, __pyx_L3_error) __pyx_v_fire_ = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(values[4], PyBUF_WRITABLE); if (unlikely(!__pyx_v_fire_.memview)) __PYX_ERR(1, 1499, __pyx_L3_error) if (values[5]) { __pyx_v_reduce_factor_ = __Pyx_PyInt_As_unsigned_short(values[5]); if (unlikely((__pyx_v_reduce_factor_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 1502, __pyx_L3_error) } else { __pyx_v_reduce_factor_ = ((unsigned short)3); } if (values[6]) { __pyx_v_fire_intensity_ = __Pyx_PyInt_As_unsigned_short(values[6]); if (unlikely((__pyx_v_fire_intensity_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 1503, __pyx_L3_error) } else { __pyx_v_fire_intensity_ = ((unsigned short)32); } if (values[7]) { __pyx_v_smooth_ = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_smooth_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1504, __pyx_L3_error) } else { __pyx_tuple__14 = PyTuple_Pack(3, __pyx_int_10, __pyx_int_80, __pyx_float_1_8); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 1514, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14);
+1515: bint transpose_ = False,
int __pyx_v_transpose_ = ((int)0); /* … */ __pyx_v_transpose_ = ((int)0); } if (values[19]) { __pyx_v_border_ = __Pyx_PyObject_IsTrue(values[19]); if (unlikely((__pyx_v_border_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1516, __pyx_L3_error) } else {
+1516: bint border_ = False,
int __pyx_v_border_ = ((int)0); /* … */ __pyx_v_border_ = ((int)0); } if (values[20]) { __pyx_v_blur_ = __Pyx_PyObject_IsTrue(values[20]); if (unlikely((__pyx_v_blur_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1517, __pyx_L3_error) } else {
+1517: bint blur_ = True
int __pyx_v_blur_ = ((int)1); PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_effect", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_reduce_factor_ = __pyx_optional_args->reduce_factor_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_fire_intensity_ = __pyx_optional_args->fire_intensity_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_smooth_ = __pyx_optional_args->smooth_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_bloom_ = __pyx_optional_args->bloom_; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_fast_bloom_ = __pyx_optional_args->fast_bloom_; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_bpf_threshold_ = __pyx_optional_args->bpf_threshold_; if (__pyx_optional_args->__pyx_n > 6) { __pyx_v_low_ = __pyx_optional_args->low_; if (__pyx_optional_args->__pyx_n > 7) { __pyx_v_high_ = __pyx_optional_args->high_; if (__pyx_optional_args->__pyx_n > 8) { __pyx_v_brightness_ = __pyx_optional_args->brightness_; if (__pyx_optional_args->__pyx_n > 9) { __pyx_v_brightness_intensity_ = __pyx_optional_args->brightness_intensity_; if (__pyx_optional_args->__pyx_n > 10) { __pyx_v_surface_ = __pyx_optional_args->surface_; if (__pyx_optional_args->__pyx_n > 11) { __pyx_v_adjust_palette_ = __pyx_optional_args->adjust_palette_; if (__pyx_optional_args->__pyx_n > 12) { __pyx_v_hsl_ = __pyx_optional_args->hsl_; if (__pyx_optional_args->__pyx_n > 13) { __pyx_v_transpose_ = __pyx_optional_args->transpose_; if (__pyx_optional_args->__pyx_n > 14) { __pyx_v_border_ = __pyx_optional_args->border_; if (__pyx_optional_args->__pyx_n > 15) { __pyx_v_blur_ = __pyx_optional_args->blur_; } } } } } } } } } } } } } } } } } /* … */ __pyx_v_blur_ = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fire_effect", 0, 5, 21, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1494, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.fire_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_hsl_), (&PyTuple_Type), 1, "hsl_", 1))) __PYX_ERR(1, 1514, __pyx_L1_error) __pyx_r = __pyx_pf_6shader_86fire_effect(__pyx_self, __pyx_v_width_, __pyx_v_height_, __pyx_v_factor_, __pyx_v_palette_, __pyx_v_fire_, __pyx_v_reduce_factor_, __pyx_v_fire_intensity_, __pyx_v_smooth_, __pyx_v_bloom_, __pyx_v_fast_bloom_, __pyx_v_bpf_threshold_, __pyx_v_low_, __pyx_v_high_, __pyx_v_brightness_, __pyx_v_brightness_intensity_, __pyx_v_surface_, __pyx_v_adjust_palette_, __pyx_v_hsl_, __pyx_v_transpose_, __pyx_v_border_, __pyx_v_blur_);
1518: ):
1519: """
1520: FIRE SHADER EFFECT
1521:
1522: * FIRE TEXTURE SIZES
1523:
1524: input width_ : integer,
1525: input height_ : integer
1526:
1527: width_ and height_ values define the size of the texture e.g Surface(width x height)
1528:
1529: * FIRE ASPECT (CONTROL OVER THE WIDTH):
1530:
1531: inputs low_ : integer
1532: input high_ : integer
1533:
1534: Optional arguments low_ & high_ (integer values) define the width 's limits of the fire effect.
1535: low_ for the starting point and high_ for the ending of the effect.
1536: e.g low_ = 10 and high_ = 200. The fire effect will be contain within width = 10 and 200
1537: low_ & high_ values must be in range [0 ... width_]
1538:
1539: * FIRE HEIGHT:
1540:
1541: input factor_ : float
1542:
1543: The fire maximum height can be adjust with the variable factor_ (float value)
1544: value > 3.95 will contain the effect within the display
1545: value < 3.95 will enlarge the effect over the display height
1546: Recommended value is 3.95 with reduce_factor_ = 3 otherwise adjust the value manually
1547: to contain the fire effect within the display
1548:
1549: * SPEED CONSIDERATION
1550:
1551: input reduce_factor_ : integer
1552:
1553: The argument reduce_factor_ control the size of the texture to be processed
1554: e.g : a value of 2, divide by 4 the pygame surface define by the values (width_ & height_)
1555: Smaller texture improve the overall performances but will slightly degrade the fire aspect,
1556: especially if the blur and smooth option are not enabled.
1557: Recommended value for reduce_factor_ is 3 (fast process)
1558: reduce_factor_ values must be an integer in range [ 0 ... 4]
1559: The reduce_factor_ value will have a significant impact on the fire effect maximum height,
1560: adjust the argument factor_ accordingly
1561:
1562: * FIRE INTENSITY AT THE SOURCE
1563:
1564: input fire_intensity_: integer
1565:
1566: Set the fire intensity with the variable fire_intensity_, 0 low flame,
1567: 32 maximum flame effect
1568: Values must be an int in range [0 ... 32]
1569:
1570: * SMOOTHING THE EFFECT
1571:
1572: input smooth_: True | False
1573:
1574: When smooth_ is True the algorithm will use the pygame function smoothscale (bi-linear
1575: filtering) or False the final texture will be adjust with the scale function.
1576: Set this variable to False if you need the best performance for the effect or if you require
1577: a pixelated fire effect. Otherwise set the variable to True for a more realistic effect.
1578:
1579:
1580: * BLOOM EFFECT
1581:
1582: input bloom_ : True | False
1583: input fast_bloom_ : True | False
1584: input bpf_threshold_ : integer
1585:
1586: Fire effect produce a bright and smooth light effect to the background texture where the fire
1587: intensity is at its maximum.
1588: Use the flag fast_bloom_ for a compromise between a realistic effect and the best performances
1589: The flag fast_bloom_ define a very fast bloom algo using only the smallest texture
1590: to create a bloom effect (all the intermediate textures will be bypassed). See the bloom effect
1591: project for more details.
1592: When fast_bloom is False, all the sub-surfaces will be blit to the final effect and will
1593: produce a more realistic fire effect (this will slightly degrade the overall performances).
1594: If the fire effect is too bright, you can always adjust the bright pass filter value
1595: bpf_threshold_(this will adjust the bloom intensity)
1596: bpf_threshold_ value must be in range [ 0 ... 255]
1597: Below 128 the bloom effect will be more noticeable and above 128 only the brightest
1598: area will be enhanced.
1599:
1600: * LIGHT EFFECT INTENSITY
1601:
1602: input brightness_ : True | False
1603: input brightness_intensity_ : float
1604:
1605: When the flag is set to True, the algorithm will use an external function,
1606: <shader_brightness24_exclude_inplace_c> to increase the brightness of the effect / texture
1607: A custom color can be passed to the function defining the pixels to be ignored during the
1608: process (default is black color).
1609: the value must be in range [-1.0 ... 1.0]. Values below zero will decrease the brightness
1610: of the flame effect and positive values will increase the brightness of the effect (causing
1611: bright white patches on the fire texture).
1612: Values below -0.4 will cause the fire effect to be translucent and this effect can also be
1613: used for simulating ascending heat convection effects on a background texture.
1614:
1615:
1616: * OPTIONAL SURFACE
1617:
1618: input surface_ : pygame.Surface
1619:
1620: This is an optional surface that can be passed to the shader to improve the performances
1621: and to avoid a new surface to be generated every iterations. The surface size must match
1622: exactly the reduce texture dimensions otherwise an exception will be raise.
1623: see reduce_factor_ option to determine the fire texture size that will be processed.
1624:
1625: * COLOR PALETTE ADJUSTMENT
1626:
1627: input adjust_palette_ : True | False
1628: input hsl_ : (10, 80, 1.8)
1629:
1630: Set this flag to True to modify the color palette of the fire texture.
1631: This allow the HSL color model to be apply to the palette values
1632: You can redefine the palette when the flag is True and by customizing a tuple of 3 float
1633: values, default is (10, 80, 1.8).
1634: The first value control the palette hue value, the second is for the saturation and last,
1635: the palette color lightness.
1636: With the variable hsl_ you can rotate the palette colors and define a new flame
1637: aspect/color/intensity
1638: If adjust_palette_ is True the original palette define by the argument palette_, will
1639: be disregarded.Instead a new palette will be created with the hsl values
1640:
1641: * FLAME ORIENTATION / DIRECTION & BORDER FLAME EFFECT
1642:
1643: input transpose_ = True | False,
1644: input border_ = True | False,
1645:
1646: transpose_ = True, this will transpose the final array
1647: for e.g :
1648: If the final fire texture is (w, h) after setting the transpose flag, the final
1649: fire texture will become (h, w). As a result the fire effect will be transversal (starting
1650: from the right of the display to the left side).
1651: You can always transpose / flip the texture to get the right flame orientation
1652: BORDER FLAME EFFECT
1653: border_ = True to create a flame effect burning the edge of the display. This version is only
1654: compatible with symmetrical display or textures (same width & height). If the display
1655: is asymmetric, the final border fire effect will be shown within the display and not neccessary
1656: on the frame border
1657:
1658: * FINAL TOUCH
1659:
1660: input blur_ : True | False
1661:
1662: This will will blur the fire effect for a more realistic appearance, remove all the jagged
1663: edge when and pixelated effect
1664:
1665:
1666: :param width_ : integer; Size (width) of the surface or display in pixels
1667: :param height_ : integer; size (height) of the surface or display in pixels
1668: :param factor_ : float; Value controlling the fire height value
1669: must be in range [3.95 ... 4.2].
1670: The value 3.95 gives the highest flame effect
1671: :param palette_ : numpy.ndarray, buffer containing mapped RGB colors (uint values)
1672: :param fire_ : numpy.ndarray shape (w, h) containing float values (fire intensity).
1673: For better performance it is advised to set the array to the size
1674: of the texture after applying the reduction_factor_.
1675: For example if the reduction_factor_ is 2, the texture would have
1676: width >> 1 and height >> 1 and the fire_array should be set to
1677: numpy.empty((height >> 1, width >> 1), float32)
1678: :param reduce_factor_ : unsigned short int ; Can be either 0, 1, 2, 3, 4.
1679: 2 and 3 provide the best performance and the best looking effect.
1680: :param fire_intensity_ : Integer; Control the original amount of energy at the
1681: bottom of the fire, must be in range of [0 ... 32].
1682: 32 being the maximum value and the maximum fire intensity
1683: :param smooth_ : boolean; True smoothscale (bi-linear filtering) or
1684: scale algorithm jagged edges (mush faster)
1685: :param bloom_ : boolean; True or False, True apply a bloom effect to the fire effect
1686: :param fast_bloom_ : boolean; Fastest bloom. This reduce the amount of calculation
1687: :param bpf_threshold_ : integer; control the bright pass filter threshold
1688: value, must be in range [0 ... 255].
1689: Maximum brightness amplification with threshold = 0,
1690: when bpf_threshold_ = 255, no change.
1691: :param low_ : integer; Starting position x for the fire effect
1692: :param high_ : integer; Ending position x for the fire effect
1693: :param brightness_ : boolean; True apply a bright filter shader to the array.
1694: Increase overall brightness of the effect
1695: :param brightness_intensity_: float; must be in range [-1.0 ... 1.0] control
1696: the brightness intensity
1697: of the effect
1698: :param surface_ : pygame.Surface. Pass a surface to the shader for
1699: better performance, otherwise a new surface will be created each
1700: calls.
1701: :param adjust_palette_ : boolean; True adjust the palette setting HSL
1702: (hue, saturation, luminescence).
1703: Be aware that if adjust_palette is True, the optional palette
1704: passed to the Shader will be disregarded
1705: :param hsl_ : tuple; float values of hue, saturation and luminescence.
1706: Hue in range [0.0 ... 100], saturation [0...100],
1707: luminescence [0.0 ... 2.0]
1708: :param transpose_ : boolean; Transpose the array (w, h) become (h, w).
1709: The fire effect will start from the left and move to the right
1710: :param border_ : boolean; Flame effect affect the border of the texture
1711: :param blur_ : boolean; Blur the fire effect
1712: :return : Return a pygame surface that can be blit directly to the game display
1713:
1714: """
1715: # todo reduce_factor=0 and border = True crash
1716:
+1717: assert reduce_factor_ in (0, 1, 2, 3, 4), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { switch (__pyx_v_reduce_factor_) { case 0: case 1: case 2: case 3: case 4: __pyx_t_1 = 1; break; default: __pyx_t_1 = 0; break; } if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_reduce_factor_must_be_i); __PYX_ERR(1, 1717, __pyx_L1_error) } } #endif
1718: "Argument reduce factor must be in range 0 ... 4 " \
1719: "\n reduce_factor_ = 1 correspond to dividing the image size by 2" \
1720: "\n reduce_factor_ = 2 correspond to dividing the image size by 4"
+1721: assert 0 <= fire_intensity_ < 33, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (0 <= __pyx_v_fire_intensity_); if (__pyx_t_1) { __pyx_t_1 = (__pyx_v_fire_intensity_ < 33); } if (unlikely(!(__pyx_t_1 != 0))) {
+1722: "Argument fire_intensity_ must be in range [0 ... 32] got %s" % fire_intensity_
__pyx_t_2 = __Pyx_PyInt_From_unsigned_short(__pyx_v_fire_intensity_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Argument_fire_intensity__must_be, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 1721, __pyx_L1_error) } } #endif
1723:
+1724: assert width_ > 0 and height_ > 0, "Argument width or height cannot be null or < 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_4 = ((__pyx_v_width_ > 0) != 0); if (__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L3_bool_binop_done; } __pyx_t_4 = ((__pyx_v_height_ > 0) != 0); __pyx_t_1 = __pyx_t_4; __pyx_L3_bool_binop_done:; if (unlikely(!__pyx_t_1)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_width_or_height_cannot); __PYX_ERR(1, 1724, __pyx_L1_error) } } #endif
+1725: assert factor_ > 0, "Argument factor_ cannot be null or < 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_factor_ > 0.0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_factor__cannot_be_null); __PYX_ERR(1, 1725, __pyx_L1_error) } } #endif
1726:
+1727: return shader_fire_effect_c(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_5.__pyx_n = 16; __pyx_t_5.reduce_factor_ = __pyx_v_reduce_factor_; __pyx_t_5.fire_intensity_ = __pyx_v_fire_intensity_; __pyx_t_5.smooth_ = __pyx_v_smooth_; __pyx_t_5.bloom_ = __pyx_v_bloom_; __pyx_t_5.fast_bloom_ = __pyx_v_fast_bloom_; __pyx_t_5.bpf_threshold_ = __pyx_v_bpf_threshold_; __pyx_t_5.low_ = __pyx_v_low_; __pyx_t_5.high_ = __pyx_v_high_; __pyx_t_5.brightness_ = __pyx_v_brightness_; __pyx_t_5.brightness_intensity_ = __pyx_v_brightness_intensity_; __pyx_t_5.surface_ = __pyx_v_surface_; __pyx_t_5.adjust_palette_ = __pyx_v_adjust_palette_; __pyx_t_5.hsl_ = __pyx_v_hsl_; __pyx_t_5.transpose_ = __pyx_v_transpose_; __pyx_t_5.border_ = __pyx_v_border_; __pyx_t_5.blur_ = __pyx_v_blur_; __pyx_t_3 = __pyx_f_6shader_shader_fire_effect_c(__pyx_v_width_, __pyx_v_height_, __pyx_v_factor_, __pyx_v_palette_, __pyx_v_fire_, &__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1728: width_, height_, factor_, palette_, fire_,
1729: reduce_factor_, fire_intensity_, smooth_,
1730: bloom_, fast_bloom_, bpf_threshold_, low_, high_, brightness_,
1731: brightness_intensity_, surface_, adjust_palette_,
1732: hsl_, transpose_, border_, blur_
1733: )
1734:
1735:
1736:
+1737: cpdef inline cloud_effect(
static PyObject *__pyx_pw_6shader_89cloud_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_cloud_effect(int __pyx_v_width_, int __pyx_v_height_, float __pyx_v_factor_, __Pyx_memviewslice __pyx_v_palette_, __Pyx_memviewslice __pyx_v_cloud_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_cloud_effect *__pyx_optional_args) { unsigned short __pyx_v_reduce_factor_ = ((unsigned short)2); unsigned short __pyx_v_cloud_intensity_ = ((unsigned short)16); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("shader.cloud_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_89cloud_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_88cloud_effect[] = "\n GENERATE CLOUD /SMOKE ON THE GAME DISPLAY \n \n * CLOUD TEXTURE SIZES \n \n input width_ : integer, \n input height_ : integer\n \n width_ and height_ values define the size of the texture e.g Surface(width x height)\n\n * CLOUD ASPECT (CONTROL OVER THE WIDTH): \n \n inputs low_ : integer \n input high_ : integer \n \n Optional arguments low_ & high_ (integer values) define the width 's limits of the cloud \n effect. low_ for the starting point and high_ for the ending of the effect.\n e.g low_ = 10 and high_ = 200. The cloud effect will be contain within width = 10 and 200\n low_ & high_ values must be in range [0 ... width_] \n \n * CLOUD HEIGHT:\n \n input factor_ : float\n \n The cloud maximum height can be adjust with the variable factor_ (float value)\n value > 3.95 will contain the effect within the display \n value < 3.95 will enlarge the effect over the display height \n Recommended value is 3.95 with reduce_factor_ = 3 otherwise adjust the value manually \n to contain the cloud effect within the display\n \n * SPEED CONSIDERATION\n \n input reduce_factor_ : integer\n \n The argument reduce_factor_ control the size of the texture to be processed \n e.g : a value of 2, divide by 4 the pygame surface define by the values (width_ & height_)\n Smaller texture improve the overall performances but will slightly degrade the cloud aspect, \n especially if the blur and smooth option are not enabled.\n Recommended value for reduce_factor_ is 3 (fast process) \n reduce_factor_ values must be an integer in range [ 0 ... 4] \n The reduce_factor_ value will have a significant impact on the cloud effect maximum height, \n adjust the argument factor_ accordingly\n\n * CLOUD INTENSITY AT THE SOURCE\n \n input cloud_intensity_: integer\n \n Set the cloud intensity with the variable cloud_intensity_, 0 low flame,\n 32 maxi""mum flame effect\n Values must be an int in range [0 ... 32] \n\n * SMOOTHING THE EFFECT\n \n input smooth_: True | False\n \n When smooth_ is True the algorithm will use the pygame function smoothscale (bi-linear \n filtering) or False the final texture will be adjust with the scale function.\n Set this variable to False if you need the best performance for the effect or if you require\n a pixelated cloud effect. Otherwise set the variable to True for a more realistic effect. \n \n * BLOOM EFFECT \n \n input bloom_ : True | False\n input fast_bloom_ : True | False\n input bpf_threshold_ : integer\n \n Bloom effect produce a bright and smooth light effect to the background texture where the cloud \n intensity is at its maximum.\n Use the flag fast_bloom_ for a compromise between a realistic effect and the best performances\n The flag fast_bloom_ define a very fast bloom algo using only the smallest texture \n to create a bloom effect (all the intermediate textures will be bypassed). See the bloom effect \n project for more details.\n When fast_bloom is False, all the sub-surfaces will be blit to the final effect and will \n produce a more realistic cloud effect (this will slightly degrade the overall performances). \n If the cloud effect is too bright, you can always adjust the bright pass filter value\n bpf_threshold_(this will adjust the bloom intensity)\n bpf_threshold_ value must be in range [ 0 ... 255] \n Below 128 the bloom effect will be more noticeable and above 128 only the brightest\n area will be enhanced.\n\n * LIGHT EFFECT INTENSITY\n\n input brightness_ : True | False\n input brightness_intensity_ : float\n\n When the flag is set to True, the algorithm will use an external function, \n <shader_brightness24_exclude_inplace_c> to increase the brightness of the effect / texture\n A custom color can be passed to the function ""defining the pixels to be ignored during the \n process (default is black color).\n the value must be in range [-1.0 ... 1.0]. Values below zero will decrease the brightness \n of the cloud effect and positive values will increase the brightness of the effect (causing\n bright white patches on the cloud texture). \n Values below -0.4 will cause the cloud effect to be translucent \n \n \n * OPTIONAL SURFACE\n \n input surface_ : pygame.Surface\n \n This is an optional surface that can be passed to the shader to improve the performances \n and to avoid a new surface to be generated every iterations. The surface size must match \n exactly the reduce texture dimensions otherwise an exception will be raise. \n see reduce_factor_ option to determine the cloud texture size that will be processed.\n \n\n * CLOUD ORIENTATION / DIRECTION \n \n input transpose_ = True | False,\n \n transpose_ = True, this will transpose the final array \n for e.g : \n If the final cloud texture is (w, h) after setting the transpose flag, the final \n cloud texture will become (h, w). As a result the cloud effect will be transversal (starting \n from the right of the display to the left side). \n You can always transpose / flip the texture to get the right cloud orientation \n \n * FINAL TOUCH\n \n input blur_ : True | False\n \n This will will blur the cloud effect for a more realistic appearance, remove all the jagged \n edge when and pixelated effect\n \n :param width_ : integer; Texture size (width) \n :param height_ : integer; Texture size (height)\n :param factor_ : float; Floating value used to control the size of the cloud\n effect. Value must be in range [3.95 ... 4.2]. Value > 3.95 \n will contain the smoke/ cloud effect within the display. \n "" Values < 3.95 will enlarge the smoke effect. \n :param palette_ : numpy.ndarray or cython memoryview containing the color for the \n cloud effect (buffer containing mapped RGB colors (uint values))\n :param cloud_ : numpy.ndarray shape (w, h) containing float values \n (cloud intensity). For better performance it is advised to set the\n array to the size of the texture after applying the \n reduction_factor_. For example if the reduction_factor_ is 2, \n the texture would have to be width >> 1 and height >> 1 and the \n cloud_ array should be equivalent to numpy.empty((height >> 1, \n width >> 1), float32)\n :param reduce_factor_ : integer; unsigned short int ; Can be either 0, 1, 2, 3, 4. \n 2 and 3 provide the best performance and the best looking effect.\n :param cloud_intensity_ : integer; Determine the amount of smoke the cloud\n effect will generate at the base of the effect (value must be in \n range [0 .. 260]). If you provide zero a random value between \n 0 ... 260 will be assigned. If you provide 250, a random value \n between 250 and 260 will be set for the amount of smoke. \n The highest the value, the more dense the cloud effect will be\n :param smooth_ : boolean; True use a smoothscale (bi-linear filtering) or\n False -> scale algorithm jagged edges (mush faster)\n :param bloom_ : True | False, Add a bloom effect when the flag is set to True\n Th""e bloom effect will smooth the cloud and create a dense smoke \n areas where the cloud is the brightest. \n :param fast_bloom_ : True | False; This set a fast algorithm for the bloom effect (the \n bloom effect will use the smallest texture)\n :param bpf_threshold_ : integer; Bright pass filter value must be in range [ 0 ... 255]\n 0 produce the maximum bloom effect\n :param low_ : integer; must be in range [ 0 ... width_], left position of the \n cloud effect \n :param high_ : integer; must be in range [ 0 ... height_], right position of the\n cloud effect\n :param brightness_ : True | False; Increase the brightness of the cloud effect when \n True\n :param brightness_intensity_: float; Set the brightness intensity of the cloud. The value must \n be in range [-1.0 ... +1.0]. Changing the value overtime will \n generate a realistic cloud effect. Negative value will generate \n translucent patch of smoke on the background image\n :param surface_ : Pygame.Surface; Pass a surface to the shader for\n better performance, otherwise a new surface will be created each \n calls.\n :param transpose_ : boolean; Transpose the array (w, h) become (h, w).\n The cloud effect will start from the left and move to the right\n :param blur_ : boolean; Blur the cloud effect\n :return : Return a pygame surface that can be blit directly to the game \n display\n "; static PyObject *__pyx_pw_6shader_89cloud_effect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_width_; int __pyx_v_height_; float __pyx_v_factor_; __Pyx_memviewslice __pyx_v_palette_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_cloud_ = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned short __pyx_v_reduce_factor_; unsigned short __pyx_v_cloud_intensity_; int __pyx_v_smooth_; int __pyx_v_bloom_; int __pyx_v_fast_bloom_; unsigned char __pyx_v_bpf_threshold_; unsigned int __pyx_v_low_; unsigned int __pyx_v_high_; int __pyx_v_brightness_; float __pyx_v_brightness_intensity_; PyObject *__pyx_v_surface_ = 0; int __pyx_v_transpose_; int __pyx_v_blur_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cloud_effect (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width_2,&__pyx_n_s_height_2,&__pyx_n_s_factor,&__pyx_n_s_palette,&__pyx_n_s_cloud,&__pyx_n_s_reduce_factor,&__pyx_n_s_cloud_intensity,&__pyx_n_s_smooth,&__pyx_n_s_bloom,&__pyx_n_s_fast_bloom,&__pyx_n_s_bpf_threshold_2,&__pyx_n_s_low,&__pyx_n_s_high,&__pyx_n_s_brightness,&__pyx_n_s_brightness_intensity,&__pyx_n_s_surface,&__pyx_n_s_transpose,&__pyx_n_s_blur,0}; PyObject* values[18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_88cloud_effect(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_width_, int __pyx_v_height_, float __pyx_v_factor_, __Pyx_memviewslice __pyx_v_palette_, __Pyx_memviewslice __pyx_v_cloud_, unsigned short __pyx_v_reduce_factor_, unsigned short __pyx_v_cloud_intensity_, int __pyx_v_smooth_, int __pyx_v_bloom_, int __pyx_v_fast_bloom_, unsigned char __pyx_v_bpf_threshold_, unsigned int __pyx_v_low_, unsigned int __pyx_v_high_, int __pyx_v_brightness_, float __pyx_v_brightness_intensity_, PyObject *__pyx_v_surface_, int __pyx_v_transpose_, int __pyx_v_blur_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cloud_effect", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_palette_.memview)) { __Pyx_RaiseUnboundLocalError("palette_"); __PYX_ERR(1, 1737, __pyx_L1_error) } if (unlikely(!__pyx_v_cloud_.memview)) { __Pyx_RaiseUnboundLocalError("cloud_"); __PYX_ERR(1, 1737, __pyx_L1_error) } __pyx_t_2.__pyx_n = 13; __pyx_t_2.reduce_factor_ = __pyx_v_reduce_factor_; __pyx_t_2.cloud_intensity_ = __pyx_v_cloud_intensity_; __pyx_t_2.smooth_ = __pyx_v_smooth_; __pyx_t_2.bloom_ = __pyx_v_bloom_; __pyx_t_2.fast_bloom_ = __pyx_v_fast_bloom_; __pyx_t_2.bpf_threshold_ = __pyx_v_bpf_threshold_; __pyx_t_2.low_ = __pyx_v_low_; __pyx_t_2.high_ = __pyx_v_high_; __pyx_t_2.brightness_ = __pyx_v_brightness_; __pyx_t_2.brightness_intensity_ = __pyx_v_brightness_intensity_; __pyx_t_2.surface_ = __pyx_v_surface_; __pyx_t_2.transpose_ = __pyx_v_transpose_; __pyx_t_2.blur_ = __pyx_v_blur_; __pyx_t_1 = __pyx_f_6shader_cloud_effect(__pyx_v_width_, __pyx_v_height_, __pyx_v_factor_, __pyx_v_palette_, __pyx_v_cloud_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1737, __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("shader.cloud_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_palette_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_cloud_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1738: int width_,
1739: int height_,
1740: float factor_,
1741: unsigned int [::1] palette_,
1742: float [:, ::1] cloud_,
1743:
1744: # OPTIONAL
1745: unsigned short int reduce_factor_ = 2,
1746: unsigned short int cloud_intensity_ = 16,
+1747: bint smooth_ = True,
int __pyx_v_smooth_ = ((int)1); /* … */ __pyx_v_smooth_ = ((int)1); } if (values[8]) { __pyx_v_bloom_ = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_bloom_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1748, __pyx_L3_error) } else {
+1748: bint bloom_ = False,
int __pyx_v_bloom_ = ((int)0); /* … */ __pyx_v_bloom_ = ((int)0); } if (values[9]) { __pyx_v_fast_bloom_ = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_fast_bloom_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1749, __pyx_L3_error) } else {
+1749: bint fast_bloom_ = True,
int __pyx_v_fast_bloom_ = ((int)1); unsigned char __pyx_v_bpf_threshold_ = ((unsigned char)0x80); unsigned int __pyx_v_low_ = ((unsigned int)0); unsigned int __pyx_v_high_ = ((unsigned int)0); /* … */ __pyx_v_fast_bloom_ = ((int)1); } if (values[10]) { __pyx_v_bpf_threshold_ = __Pyx_PyInt_As_unsigned_char(values[10]); if (unlikely((__pyx_v_bpf_threshold_ == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 1750, __pyx_L3_error) } else { __pyx_v_bpf_threshold_ = ((unsigned char)0x80); } if (values[11]) { __pyx_v_low_ = __Pyx_PyInt_As_unsigned_int(values[11]); if (unlikely((__pyx_v_low_ == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1751, __pyx_L3_error) } else { __pyx_v_low_ = ((unsigned int)0); } if (values[12]) { __pyx_v_high_ = __Pyx_PyInt_As_unsigned_int(values[12]); if (unlikely((__pyx_v_high_ == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1752, __pyx_L3_error) } else { __pyx_v_high_ = ((unsigned int)0); } if (values[13]) { __pyx_v_brightness_ = __Pyx_PyObject_IsTrue(values[13]); if (unlikely((__pyx_v_brightness_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1753, __pyx_L3_error) } else {
1750: unsigned char bpf_threshold_ = 128,
1751: unsigned int low_ = 0,
1752: unsigned int high_ = 0,
+1753: bint brightness_ = False,
int __pyx_v_brightness_ = ((int)0); float __pyx_v_brightness_intensity_ = ((float)0.0); /* … */ __pyx_v_brightness_ = ((int)0); } if (values[14]) { __pyx_v_brightness_intensity_ = __pyx_PyFloat_AsFloat(values[14]); if (unlikely((__pyx_v_brightness_intensity_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1754, __pyx_L3_error) } else { __pyx_v_brightness_intensity_ = ((float)0.0); } __pyx_v_surface_ = values[15]; if (values[16]) { __pyx_v_transpose_ = __Pyx_PyObject_IsTrue(values[16]); if (unlikely((__pyx_v_transpose_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1756, __pyx_L3_error) } else {
1754: float brightness_intensity_ = 0.0,
+1755: object surface_ = None,
PyObject *__pyx_v_surface_ = ((PyObject *)Py_None); /* … */ values[15] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); CYTHON_FALLTHROUGH; case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); CYTHON_FALLTHROUGH; case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); CYTHON_FALLTHROUGH; case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_2)) != 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_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cloud_effect", 0, 5, 18, 1); __PYX_ERR(1, 1737, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cloud_effect", 0, 5, 18, 2); __PYX_ERR(1, 1737, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_palette)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cloud_effect", 0, 5, 18, 3); __PYX_ERR(1, 1737, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cloud)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("cloud_effect", 0, 5, 18, 4); __PYX_ERR(1, 1737, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_reduce_factor); if (value) { values[5] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cloud_intensity); if (value) { values[6] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_smooth); if (value) { values[7] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bloom); if (value) { values[8] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fast_bloom); if (value) { values[9] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bpf_threshold_2); if (value) { values[10] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_low); if (value) { values[11] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_high); if (value) { values[12] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 13: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_brightness); if (value) { values[13] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 14: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_brightness_intensity); if (value) { values[14] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 15: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_surface); if (value) { values[15] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 16: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_transpose); if (value) { values[16] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 17: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_blur); if (value) { values[17] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cloud_effect") < 0)) __PYX_ERR(1, 1737, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); CYTHON_FALLTHROUGH; case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); CYTHON_FALLTHROUGH; case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); CYTHON_FALLTHROUGH; case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[2] = PyTuple_GET_ITEM(__pyx_args, 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(1, 1738, __pyx_L3_error) __pyx_v_height_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1739, __pyx_L3_error) __pyx_v_factor_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_factor_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 1740, __pyx_L3_error) __pyx_v_palette_ = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_int(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_palette_.memview)) __PYX_ERR(1, 1741, __pyx_L3_error) __pyx_v_cloud_ = __Pyx_PyObject_to_MemoryviewSlice_d_dc_float(values[4], PyBUF_WRITABLE); if (unlikely(!__pyx_v_cloud_.memview)) __PYX_ERR(1, 1742, __pyx_L3_error) if (values[5]) { __pyx_v_reduce_factor_ = __Pyx_PyInt_As_unsigned_short(values[5]); if (unlikely((__pyx_v_reduce_factor_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 1745, __pyx_L3_error) } else { __pyx_v_reduce_factor_ = ((unsigned short)2); } if (values[6]) { __pyx_v_cloud_intensity_ = __Pyx_PyInt_As_unsigned_short(values[6]); if (unlikely((__pyx_v_cloud_intensity_ == (unsigned short)-1) && PyErr_Occurred())) __PYX_ERR(1, 1746, __pyx_L3_error) } else { __pyx_v_cloud_intensity_ = ((unsigned short)16); } if (values[7]) { __pyx_v_smooth_ = __Pyx_PyObject_IsTrue(values[7]); if (unlikely((__pyx_v_smooth_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1747, __pyx_L3_error) } else {
+1756: bint transpose_ = False,
int __pyx_v_transpose_ = ((int)0); /* … */ __pyx_v_transpose_ = ((int)0); } if (values[17]) { __pyx_v_blur_ = __Pyx_PyObject_IsTrue(values[17]); if (unlikely((__pyx_v_blur_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 1757, __pyx_L3_error) } else {
+1757: bint blur_ = True
int __pyx_v_blur_ = ((int)1); PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cloud_effect", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_reduce_factor_ = __pyx_optional_args->reduce_factor_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_cloud_intensity_ = __pyx_optional_args->cloud_intensity_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_smooth_ = __pyx_optional_args->smooth_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_bloom_ = __pyx_optional_args->bloom_; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_fast_bloom_ = __pyx_optional_args->fast_bloom_; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_bpf_threshold_ = __pyx_optional_args->bpf_threshold_; if (__pyx_optional_args->__pyx_n > 6) { __pyx_v_low_ = __pyx_optional_args->low_; if (__pyx_optional_args->__pyx_n > 7) { __pyx_v_high_ = __pyx_optional_args->high_; if (__pyx_optional_args->__pyx_n > 8) { __pyx_v_brightness_ = __pyx_optional_args->brightness_; if (__pyx_optional_args->__pyx_n > 9) { __pyx_v_brightness_intensity_ = __pyx_optional_args->brightness_intensity_; if (__pyx_optional_args->__pyx_n > 10) { __pyx_v_surface_ = __pyx_optional_args->surface_; if (__pyx_optional_args->__pyx_n > 11) { __pyx_v_transpose_ = __pyx_optional_args->transpose_; if (__pyx_optional_args->__pyx_n > 12) { __pyx_v_blur_ = __pyx_optional_args->blur_; } } } } } } } } } } } } } } /* … */ __pyx_v_blur_ = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cloud_effect", 0, 5, 18, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1737, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.cloud_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_88cloud_effect(__pyx_self, __pyx_v_width_, __pyx_v_height_, __pyx_v_factor_, __pyx_v_palette_, __pyx_v_cloud_, __pyx_v_reduce_factor_, __pyx_v_cloud_intensity_, __pyx_v_smooth_, __pyx_v_bloom_, __pyx_v_fast_bloom_, __pyx_v_bpf_threshold_, __pyx_v_low_, __pyx_v_high_, __pyx_v_brightness_, __pyx_v_brightness_intensity_, __pyx_v_surface_, __pyx_v_transpose_, __pyx_v_blur_);
1758: ):
1759: """
1760: GENERATE CLOUD /SMOKE ON THE GAME DISPLAY
1761:
1762: * CLOUD TEXTURE SIZES
1763:
1764: input width_ : integer,
1765: input height_ : integer
1766:
1767: width_ and height_ values define the size of the texture e.g Surface(width x height)
1768:
1769: * CLOUD ASPECT (CONTROL OVER THE WIDTH):
1770:
1771: inputs low_ : integer
1772: input high_ : integer
1773:
1774: Optional arguments low_ & high_ (integer values) define the width 's limits of the cloud
1775: effect. low_ for the starting point and high_ for the ending of the effect.
1776: e.g low_ = 10 and high_ = 200. The cloud effect will be contain within width = 10 and 200
1777: low_ & high_ values must be in range [0 ... width_]
1778:
1779: * CLOUD HEIGHT:
1780:
1781: input factor_ : float
1782:
1783: The cloud maximum height can be adjust with the variable factor_ (float value)
1784: value > 3.95 will contain the effect within the display
1785: value < 3.95 will enlarge the effect over the display height
1786: Recommended value is 3.95 with reduce_factor_ = 3 otherwise adjust the value manually
1787: to contain the cloud effect within the display
1788:
1789: * SPEED CONSIDERATION
1790:
1791: input reduce_factor_ : integer
1792:
1793: The argument reduce_factor_ control the size of the texture to be processed
1794: e.g : a value of 2, divide by 4 the pygame surface define by the values (width_ & height_)
1795: Smaller texture improve the overall performances but will slightly degrade the cloud aspect,
1796: especially if the blur and smooth option are not enabled.
1797: Recommended value for reduce_factor_ is 3 (fast process)
1798: reduce_factor_ values must be an integer in range [ 0 ... 4]
1799: The reduce_factor_ value will have a significant impact on the cloud effect maximum height,
1800: adjust the argument factor_ accordingly
1801:
1802: * CLOUD INTENSITY AT THE SOURCE
1803:
1804: input cloud_intensity_: integer
1805:
1806: Set the cloud intensity with the variable cloud_intensity_, 0 low flame,
1807: 32 maximum flame effect
1808: Values must be an int in range [0 ... 32]
1809:
1810: * SMOOTHING THE EFFECT
1811:
1812: input smooth_: True | False
1813:
1814: When smooth_ is True the algorithm will use the pygame function smoothscale (bi-linear
1815: filtering) or False the final texture will be adjust with the scale function.
1816: Set this variable to False if you need the best performance for the effect or if you require
1817: a pixelated cloud effect. Otherwise set the variable to True for a more realistic effect.
1818:
1819: * BLOOM EFFECT
1820:
1821: input bloom_ : True | False
1822: input fast_bloom_ : True | False
1823: input bpf_threshold_ : integer
1824:
1825: Bloom effect produce a bright and smooth light effect to the background texture where the cloud
1826: intensity is at its maximum.
1827: Use the flag fast_bloom_ for a compromise between a realistic effect and the best performances
1828: The flag fast_bloom_ define a very fast bloom algo using only the smallest texture
1829: to create a bloom effect (all the intermediate textures will be bypassed). See the bloom effect
1830: project for more details.
1831: When fast_bloom is False, all the sub-surfaces will be blit to the final effect and will
1832: produce a more realistic cloud effect (this will slightly degrade the overall performances).
1833: If the cloud effect is too bright, you can always adjust the bright pass filter value
1834: bpf_threshold_(this will adjust the bloom intensity)
1835: bpf_threshold_ value must be in range [ 0 ... 255]
1836: Below 128 the bloom effect will be more noticeable and above 128 only the brightest
1837: area will be enhanced.
1838:
1839: * LIGHT EFFECT INTENSITY
1840:
1841: input brightness_ : True | False
1842: input brightness_intensity_ : float
1843:
1844: When the flag is set to True, the algorithm will use an external function,
1845: <shader_brightness24_exclude_inplace_c> to increase the brightness of the effect / texture
1846: A custom color can be passed to the function defining the pixels to be ignored during the
1847: process (default is black color).
1848: the value must be in range [-1.0 ... 1.0]. Values below zero will decrease the brightness
1849: of the cloud effect and positive values will increase the brightness of the effect (causing
1850: bright white patches on the cloud texture).
1851: Values below -0.4 will cause the cloud effect to be translucent
1852:
1853:
1854: * OPTIONAL SURFACE
1855:
1856: input surface_ : pygame.Surface
1857:
1858: This is an optional surface that can be passed to the shader to improve the performances
1859: and to avoid a new surface to be generated every iterations. The surface size must match
1860: exactly the reduce texture dimensions otherwise an exception will be raise.
1861: see reduce_factor_ option to determine the cloud texture size that will be processed.
1862:
1863:
1864: * CLOUD ORIENTATION / DIRECTION
1865:
1866: input transpose_ = True | False,
1867:
1868: transpose_ = True, this will transpose the final array
1869: for e.g :
1870: If the final cloud texture is (w, h) after setting the transpose flag, the final
1871: cloud texture will become (h, w). As a result the cloud effect will be transversal (starting
1872: from the right of the display to the left side).
1873: You can always transpose / flip the texture to get the right cloud orientation
1874:
1875: * FINAL TOUCH
1876:
1877: input blur_ : True | False
1878:
1879: This will will blur the cloud effect for a more realistic appearance, remove all the jagged
1880: edge when and pixelated effect
1881:
1882: :param width_ : integer; Texture size (width)
1883: :param height_ : integer; Texture size (height)
1884: :param factor_ : float; Floating value used to control the size of the cloud
1885: effect. Value must be in range [3.95 ... 4.2]. Value > 3.95
1886: will contain the smoke/ cloud effect within the display.
1887: Values < 3.95 will enlarge the smoke effect.
1888: :param palette_ : numpy.ndarray or cython memoryview containing the color for the
1889: cloud effect (buffer containing mapped RGB colors (uint values))
1890: :param cloud_ : numpy.ndarray shape (w, h) containing float values
1891: (cloud intensity). For better performance it is advised to set the
1892: array to the size of the texture after applying the
1893: reduction_factor_. For example if the reduction_factor_ is 2,
1894: the texture would have to be width >> 1 and height >> 1 and the
1895: cloud_ array should be equivalent to numpy.empty((height >> 1,
1896: width >> 1), float32)
1897: :param reduce_factor_ : integer; unsigned short int ; Can be either 0, 1, 2, 3, 4.
1898: 2 and 3 provide the best performance and the best looking effect.
1899: :param cloud_intensity_ : integer; Determine the amount of smoke the cloud
1900: effect will generate at the base of the effect (value must be in
1901: range [0 .. 260]). If you provide zero a random value between
1902: 0 ... 260 will be assigned. If you provide 250, a random value
1903: between 250 and 260 will be set for the amount of smoke.
1904: The highest the value, the more dense the cloud effect will be
1905: :param smooth_ : boolean; True use a smoothscale (bi-linear filtering) or
1906: False -> scale algorithm jagged edges (mush faster)
1907: :param bloom_ : True | False, Add a bloom effect when the flag is set to True
1908: The bloom effect will smooth the cloud and create a dense smoke
1909: areas where the cloud is the brightest.
1910: :param fast_bloom_ : True | False; This set a fast algorithm for the bloom effect (the
1911: bloom effect will use the smallest texture)
1912: :param bpf_threshold_ : integer; Bright pass filter value must be in range [ 0 ... 255]
1913: 0 produce the maximum bloom effect
1914: :param low_ : integer; must be in range [ 0 ... width_], left position of the
1915: cloud effect
1916: :param high_ : integer; must be in range [ 0 ... height_], right position of the
1917: cloud effect
1918: :param brightness_ : True | False; Increase the brightness of the cloud effect when
1919: True
1920: :param brightness_intensity_: float; Set the brightness intensity of the cloud. The value must
1921: be in range [-1.0 ... +1.0]. Changing the value overtime will
1922: generate a realistic cloud effect. Negative value will generate
1923: translucent patch of smoke on the background image
1924: :param surface_ : Pygame.Surface; Pass a surface to the shader for
1925: better performance, otherwise a new surface will be created each
1926: calls.
1927: :param transpose_ : boolean; Transpose the array (w, h) become (h, w).
1928: The cloud effect will start from the left and move to the right
1929: :param blur_ : boolean; Blur the cloud effect
1930: :return : Return a pygame surface that can be blit directly to the game
1931: display
1932: """
1933:
+1934: assert reduce_factor_ in (0, 1, 2, 3, 4), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { switch (__pyx_v_reduce_factor_) { case 0: case 1: case 2: case 3: case 4: __pyx_t_1 = 1; break; default: __pyx_t_1 = 0; break; } if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_reduce_factor_must_be_i); __PYX_ERR(1, 1934, __pyx_L1_error) } } #endif
1935: "Argument reduce factor must be in range 0 ... 4 " \
1936: "\n reduce_factor_ = 1 correspond to dividing the image size by 2" \
1937: "\n reduce_factor_ = 2 correspond to dividing the image size by 4"
1938:
+1939: assert width_ > 0 and height_ > 0, "Argument width or height cannot be null or < 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = ((__pyx_v_width_ > 0) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L3_bool_binop_done; } __pyx_t_2 = ((__pyx_v_height_ > 0) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L3_bool_binop_done:; if (unlikely(!__pyx_t_1)) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_width_or_height_cannot); __PYX_ERR(1, 1939, __pyx_L1_error) } } #endif
+1940: assert factor_ > 0, "Argument factor_ cannot be null or < 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_factor_ > 0.0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_factor__cannot_be_null); __PYX_ERR(1, 1940, __pyx_L1_error) } } #endif
1941:
+1942: return shader_cloud_effect_c(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_4.__pyx_n = 13; __pyx_t_4.reduce_factor_ = __pyx_v_reduce_factor_; __pyx_t_4.cloud_intensity_ = __pyx_v_cloud_intensity_; __pyx_t_4.smooth_ = __pyx_v_smooth_; __pyx_t_4.bloom_ = __pyx_v_bloom_; __pyx_t_4.fast_bloom_ = __pyx_v_fast_bloom_; __pyx_t_4.bpf_threshold_ = __pyx_v_bpf_threshold_; __pyx_t_4.low_ = __pyx_v_low_; __pyx_t_4.high_ = __pyx_v_high_; __pyx_t_4.brightness_ = __pyx_v_brightness_; __pyx_t_4.brightness_intensity_ = __pyx_v_brightness_intensity_; __pyx_t_4.surface_ = __pyx_v_surface_; __pyx_t_4.transpose_ = __pyx_v_transpose_; __pyx_t_4.blur_ = __pyx_v_blur_; __pyx_t_3 = __pyx_f_6shader_shader_cloud_effect_c(__pyx_v_width_, __pyx_v_height_, __pyx_v_factor_, __pyx_v_palette_, __pyx_v_cloud_, &__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1943: width_, height_, factor_, palette_, cloud_,
1944: reduce_factor_, cloud_intensity_, smooth_,
1945: bloom_, fast_bloom_, bpf_threshold_, low_, high_, brightness_,
1946: brightness_intensity_, surface_, transpose_, blur_
1947: )
1948:
1949:
1950:
+1951: cpdef inline mirroring_array(object surface_):
static PyObject *__pyx_pw_6shader_91mirroring_array(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_mirroring_array(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring_array", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_AddTraceback("shader.mirroring_array", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_91mirroring_array(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_90mirroring_array[] = "\n \n SHADER MIRRORING\n\n This method create a mirror image \n \n Compatible 24 - 32 bit image / surface\n \n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return : returns a numpy ndarray shape (w, h, 3) \n \n "; static PyObject *__pyx_pw_6shader_91mirroring_array(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring_array (wrapper)", 0); __pyx_r = __pyx_pf_6shader_90mirroring_array(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_90mirroring_array(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring_array", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_mirroring_array(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1951, __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("shader.mirroring_array", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1952: """
1953:
1954: SHADER MIRRORING
1955:
1956: This method create a mirror image
1957:
1958: Compatible 24 - 32 bit image / surface
1959:
1960: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1961: :return : returns a numpy ndarray shape (w, h, 3)
1962:
1963: """
+1964: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1964, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1965: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1965, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1964, __pyx_L1_error) } } #endif
1966:
+1967: return mirroring_c(pixels3d(surface_))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1967, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __pyx_f_6shader_mirroring_c(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
1968:
1969:
1970:
1971:
+1972: cpdef inline void mirroring(object surface_):
static PyObject *__pyx_pw_6shader_93mirroring(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_mirroring(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.mirroring", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_93mirroring(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_92mirroring[] = "\n SHADER MIRRORING (INPLACE)\n\n This method create a mirror image \n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return : void\n "; static PyObject *__pyx_pw_6shader_93mirroring(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring (wrapper)", 0); __pyx_r = __pyx_pf_6shader_92mirroring(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_92mirroring(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_mirroring(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1972, __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("shader.mirroring", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1973: """
1974: SHADER MIRRORING (INPLACE)
1975:
1976: This method create a mirror image
1977:
1978: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1979: :return : void
1980: """
+1981: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1981, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+1982: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 1981, __pyx_L1_error) } } #endif
1983:
+1984: mirroring_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 1984, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __pyx_f_6shader_mirroring_inplace_c(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1985:
1986: # cpdef inline transpose_inplace(object surface_):
1987: # return tranpose_c(pixels3d(surface_))
1988:
1989:
1990:
1991:
+1992: cpdef inline void sharpen(object surface_):
static PyObject *__pyx_pw_6shader_95sharpen(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_sharpen(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sharpen", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.sharpen", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_95sharpen(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_94sharpen[] = "\n \n SHARPEN IMAGE APPLYING THE BELOW 3 X 3 KERNEL OVER EVERY PIXELS.\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return : void \n "; static PyObject *__pyx_pw_6shader_95sharpen(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sharpen (wrapper)", 0); __pyx_r = __pyx_pf_6shader_94sharpen(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_94sharpen(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sharpen", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_sharpen(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1992, __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("shader.sharpen", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1993: """
1994:
1995: SHARPEN IMAGE APPLYING THE BELOW 3 X 3 KERNEL OVER EVERY PIXELS.
1996:
1997: :param surface_ : pygame.Surface; compatible 24 - 32 bit
1998: :return : void
1999: """
+2000: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2000, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2001: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2000, __pyx_L1_error) } } #endif
2002:
+2003: shader_sharpen_filter_inplace_c(pixels3d(surface_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2003, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2003, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 2003, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_f_6shader_shader_sharpen_filter_inplace_c(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
2004:
2005:
+2006: cpdef inline void dirt_lens(
static PyObject *__pyx_pw_6shader_97dirt_lens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_dirt_lens(PyObject *__pyx_v_surface_, PyObject *__pyx_v_lens_model_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_dirt_lens *__pyx_optional_args) { int __pyx_v_flag_ = __pyx_k__15; float __pyx_v_light_ = ((float)0.0); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dirt_lens", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_flag_ = __pyx_optional_args->flag_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_light_ = __pyx_optional_args->light_; } } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.dirt_lens", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_97dirt_lens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_96dirt_lens[] = "\n DIRT LENS EFFECT \n \n This function display a dirt lens texture on the top of your game display to \n simulate a camera artefact or realistic camera effect when the light from the\n scene is oriented directly toward the camera. \n \n Choose a lens texture from the Assets directory (free textures provided in Assets directory \n of this project). All textures are sizes 5184x3456 and would have to be re-sized to \n your game display and used by function `dirt_lens`. \n The function dirt_lens will not resize the texture for you.\n \n The setting light_ is a float values cap between -1.0 to 0.2 and allow you to increase the \n light source oriented toward the camera. Values <0.0 will decrease the lens dirt \n effect and values >0.0 will increase the brightness of the display and increase the \n amount of dirt on the camera lens (your display).\n \n Optionally the setting flag_ can be changed from BLEND_RGB_ADD to any other pygame optional \n flags value. BLEND_RGB_ADD is the default setting and allow the pixels from the dirt lens \n texture to be blended (added) to the display and provide the brightest and better looking \n effect. \n \n This effect can be used for real time rendering for surfaces resolution 1024x768 \n \n Assets/Bokeh__Lens_Dirt_9.jpg\n Assets/Bokeh__Lens_Dirt_38.jpg\n Assets/Bokeh__Lens_Dirt_46.jpg\n Assets/Bokeh__Lens_Dirt_50.jpg\n Assets/Bokeh__Lens_Dirt_54.jpg\n Assets/Bokeh__Lens_Dirt_67.jpg\n \n :param surface_ : Surface 24 - 32 bit represent the surface or the display \n \n :param lens_model_: Surface The Lens model is a pygame Surface. PygameShader provide a 6 \n different surfaces that can be used as a layer to generate a dirt lens effect on your game \n display. See above for the name of the free dirt lens textures. \n The texture has to be loaded prior calling this effect and passed as an argument. By default \n the textu""res sizes are 5184x3456 (width & height). The texture would have also to be re-scale \n once to the game display dimensions (e.g 1027x768) or to the size of your texture.\n \n :param flag_ : integer; pygame flags such as BLEND_RGB_ADD, BLEND_RGB_MAX etc. These flags \n will change the overall appearance of the effect blending the dirt lens\n image with a different mathematical expression. BLEND_RGB_ADD is the \n default flag and blend together the dirt_lens and the game display \n providing a very bright aspect and vivid effect.\n \n :param light_ : float; Float value cap between [-1.0 ... 0.2] to increase or decrease \n the overall brightness of the dirt lens texture. Tis setting can be used to simulate a \n texture transition when sweeping the values from -1.0 toward 0.2 by a small increment.\n Values < 0 will tend to diminish the effect and values > 0 will increase the brightness \n and the dirt lens effect. \n \n :return: void \n "; static PyObject *__pyx_pw_6shader_97dirt_lens(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; PyObject *__pyx_v_lens_model_ = 0; int __pyx_v_flag_; float __pyx_v_light_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dirt_lens (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_lens_model,&__pyx_n_s_flag,&__pyx_n_s_light,0}; PyObject* values[4] = {0,0,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 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_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_lens_model)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("dirt_lens", 0, 2, 4, 1); __PYX_ERR(1, 2006, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flag); 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_light); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dirt_lens") < 0)) __PYX_ERR(1, 2006, __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_surface_ = values[0]; __pyx_v_lens_model_ = values[1]; if (values[2]) { __pyx_v_flag_ = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flag_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2009, __pyx_L3_error) } else { __pyx_v_flag_ = __pyx_k__15; } if (values[3]) { __pyx_v_light_ = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_light_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 2010, __pyx_L3_error) } else { __pyx_v_light_ = ((float)0.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dirt_lens", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2006, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.dirt_lens", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_96dirt_lens(__pyx_self, __pyx_v_surface_, __pyx_v_lens_model_, __pyx_v_flag_, __pyx_v_light_); 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_6shader_96dirt_lens(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, PyObject *__pyx_v_lens_model_, int __pyx_v_flag_, float __pyx_v_light_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dirt_lens", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 2; __pyx_t_1.flag_ = __pyx_v_flag_; __pyx_t_1.light_ = __pyx_v_light_; __pyx_f_6shader_dirt_lens(__pyx_v_surface_, __pyx_v_lens_model_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.dirt_lens", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2007: object surface_,
2008: object lens_model_,
+2009: int flag_=BLEND_RGB_ADD,
__Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 2009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_33); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2009, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __pyx_k__15 = __pyx_t_7; /* … */ __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 2009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); /* … */ __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_33); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2009, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __pyx_k__15 = __pyx_t_7;
2010: float light_ = 0.0
2011: ):
2012: """
2013: DIRT LENS EFFECT
2014:
2015: This function display a dirt lens texture on the top of your game display to
2016: simulate a camera artefact or realistic camera effect when the light from the
2017: scene is oriented directly toward the camera.
2018:
2019: Choose a lens texture from the Assets directory (free textures provided in Assets directory
2020: of this project). All textures are sizes 5184x3456 and would have to be re-sized to
2021: your game display and used by function `dirt_lens`.
2022: The function dirt_lens will not resize the texture for you.
2023:
2024: The setting light_ is a float values cap between -1.0 to 0.2 and allow you to increase the
2025: light source oriented toward the camera. Values <0.0 will decrease the lens dirt
2026: effect and values >0.0 will increase the brightness of the display and increase the
2027: amount of dirt on the camera lens (your display).
2028:
2029: Optionally the setting flag_ can be changed from BLEND_RGB_ADD to any other pygame optional
2030: flags value. BLEND_RGB_ADD is the default setting and allow the pixels from the dirt lens
2031: texture to be blended (added) to the display and provide the brightest and better looking
2032: effect.
2033:
2034: This effect can be used for real time rendering for surfaces resolution 1024x768
2035:
2036: Assets/Bokeh__Lens_Dirt_9.jpg
2037: Assets/Bokeh__Lens_Dirt_38.jpg
2038: Assets/Bokeh__Lens_Dirt_46.jpg
2039: Assets/Bokeh__Lens_Dirt_50.jpg
2040: Assets/Bokeh__Lens_Dirt_54.jpg
2041: Assets/Bokeh__Lens_Dirt_67.jpg
2042:
2043: :param surface_ : Surface 24 - 32 bit represent the surface or the display
2044:
2045: :param lens_model_: Surface The Lens model is a pygame Surface. PygameShader provide a 6
2046: different surfaces that can be used as a layer to generate a dirt lens effect on your game
2047: display. See above for the name of the free dirt lens textures.
2048: The texture has to be loaded prior calling this effect and passed as an argument. By default
2049: the textures sizes are 5184x3456 (width & height). The texture would have also to be re-scale
2050: once to the game display dimensions (e.g 1027x768) or to the size of your texture.
2051:
2052: :param flag_ : integer; pygame flags such as BLEND_RGB_ADD, BLEND_RGB_MAX etc. These flags
2053: will change the overall appearance of the effect blending the dirt lens
2054: image with a different mathematical expression. BLEND_RGB_ADD is the
2055: default flag and blend together the dirt_lens and the game display
2056: providing a very bright aspect and vivid effect.
2057:
2058: :param light_ : float; Float value cap between [-1.0 ... 0.2] to increase or decrease
2059: the overall brightness of the dirt lens texture. Tis setting can be used to simulate a
2060: texture transition when sweeping the values from -1.0 toward 0.2 by a small increment.
2061: Values < 0 will tend to diminish the effect and values > 0 will increase the brightness
2062: and the dirt lens effect.
2063:
2064: :return: void
2065: """
+2066: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2066, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2066, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2067: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2066, __pyx_L1_error) } } #endif
2068:
+2069: assert PyObject_IsInstance(lens_model_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pygame); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_lens_model_, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2069, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2070: "\nArgument lens_model_ must be a pygame.Surface type, got %s " % type(lens_model_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_lens_model__must_be_a, ((PyObject *)Py_TYPE(__pyx_v_lens_model_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2070, __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(1, 2069, __pyx_L1_error) } } #endif
2071:
+2072: assert PyObject_IsInstance(light_, float), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = PyFloat_FromDouble(__pyx_v_light_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_IsInstance(__pyx_t_1, ((PyObject *)(&PyFloat_Type))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2072, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2073: "\nArgument light_ must be a float type, got %s " % type(light_)
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_light_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_light__must_be_a_float, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2072, __pyx_L1_error) } } #endif
2074:
+2075: if light_ > 0.2:
__pyx_t_3 = ((__pyx_v_light_ > 0.2) != 0); if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+2076: light_ = 0.2
__pyx_v_light_ = 0.2;
+2077: elif light_ < -1.0:
__pyx_t_3 = ((__pyx_v_light_ < -1.0) != 0); if (__pyx_t_3) { /* … */ } __pyx_L3:;
+2078: light_ = 1.0
__pyx_v_light_ = 1.0;
2079:
+2080: assert PyObject_IsInstance(flag_, int), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_flag_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_IsInstance(__pyx_t_2, ((PyObject *)(&PyInt_Type))); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2080, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2081: "\nArgument flag_ must be a int type, got %s " % type(flag_)
__pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_flag_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_flag__must_be_a_int_ty, ((PyObject *)Py_TYPE(__pyx_t_2))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 2080, __pyx_L1_error) } } #endif
2082:
+2083: dirt_lens_c(surface_, lens_model_, flag_, light_)
__pyx_t_4.__pyx_n = 1; __pyx_t_4.light_ = __pyx_v_light_; __pyx_f_6shader_dirt_lens_c(__pyx_v_surface_, __pyx_v_lens_model_, __pyx_v_flag_, &__pyx_t_4);
2084:
2085:
2086: # *******************************************************************
2087:
2088: @cython.binding(False)
2089: @cython.boundscheck(False)
2090: @cython.wraparound(False)
2091: @cython.nonecheck(False)
2092: @cython.cdivision(True)
+2093: cpdef inline void end_game(object surface):
static PyObject *__pyx_pw_6shader_99end_game(PyObject *__pyx_self, PyObject *__pyx_v_surface); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_end_game(CYTHON_UNUSED PyObject *__pyx_v_surface, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("end_game", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("shader.end_game", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_99end_game(PyObject *__pyx_self, PyObject *__pyx_v_surface); /*proto*/ static char __pyx_doc_6shader_98end_game[] = "\n \n :param surface: \n :return: \n "; static PyObject *__pyx_pw_6shader_99end_game(PyObject *__pyx_self, PyObject *__pyx_v_surface) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("end_game (wrapper)", 0); __pyx_r = __pyx_pf_6shader_98end_game(__pyx_self, ((PyObject *)__pyx_v_surface)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_98end_game(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("end_game", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_end_game(__pyx_v_surface, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2093, __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("shader.end_game", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2094: """
2095:
2096: :param surface:
2097: :return:
2098: """
+2099: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2099, __pyx_L1_error)
2100:
2101: @cython.binding(False)
2102: @cython.boundscheck(False)
2103: @cython.wraparound(False)
2104: @cython.nonecheck(False)
2105: @cython.cdivision(True)
+2106: cpdef inline void level_clear(object surface):
static PyObject *__pyx_pw_6shader_101level_clear(PyObject *__pyx_self, PyObject *__pyx_v_surface); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_level_clear(CYTHON_UNUSED PyObject *__pyx_v_surface, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("level_clear", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("shader.level_clear", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_101level_clear(PyObject *__pyx_self, PyObject *__pyx_v_surface); /*proto*/ static char __pyx_doc_6shader_100level_clear[] = "\n \n :param surface: \n :return: \n "; static PyObject *__pyx_pw_6shader_101level_clear(PyObject *__pyx_self, PyObject *__pyx_v_surface) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("level_clear (wrapper)", 0); __pyx_r = __pyx_pf_6shader_100level_clear(__pyx_self, ((PyObject *)__pyx_v_surface)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_100level_clear(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("level_clear", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_level_clear(__pyx_v_surface, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2106, __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("shader.level_clear", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2107: """
2108:
2109: :param surface:
2110: :return:
2111: """
+2112: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2112, __pyx_L1_error)
2113:
2114: @cython.binding(False)
2115: @cython.boundscheck(False)
2116: @cython.wraparound(False)
2117: @cython.nonecheck(False)
2118: @cython.cdivision(True)
+2119: cpdef object dithering(object surface_, int factor_=2):
static PyObject *__pyx_pw_6shader_103dithering(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_dithering(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_dithering *__pyx_optional_args) { int __pyx_v_factor_ = ((int)2); PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_factor_ = __pyx_optional_args->factor_; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __Pyx_AddTraceback("shader.dithering", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_103dithering(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_102dithering[] = "\n Dithering is used in computer graphics to create the illusion of \"color depth\" in images with\n a limited color palette - a technique also known as color quantization. In a dithered image,\n colors that are not available in the palette are approximated by a diffusion of colored pixels\n from within the available palette. The human eye perceives the diffusion as a mixture of \n the colors within it (see color vision). Dithered images, particularly those with relatively\n few colors, can often be distinguished by a characteristic graininess or speckled appearance\n \n Take a pygame surface as argument format 24-32 bit and convert it to a 3d array format \n (w, h, 3) type float (float32, single precision). \n As the image is converted to a different data type format (uint8 to float32), \n the transformation cannot be applied inplace. The image returned by the method dithering \n is a copy of the original image. \n \n :param surface_: Pygame surface format 24-32 bit \n :param factor_ : integer; Value must be > 1 otherwise an exception will be thrown \n :return : Surface; \n \n "; static PyObject *__pyx_pw_6shader_103dithering(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_factor_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_factor,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dithering") < 0)) __PYX_ERR(1, 2119, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_factor_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_factor_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2119, __pyx_L3_error) } else { __pyx_v_factor_ = ((int)2); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dithering", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2119, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.dithering", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_102dithering(__pyx_self, __pyx_v_surface_, __pyx_v_factor_); 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_6shader_102dithering(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_factor_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.factor_ = __pyx_v_factor_; __pyx_t_1 = __pyx_f_6shader_dithering(__pyx_v_surface_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2119, __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("shader.dithering", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2120:
2121: """
2122: Dithering is used in computer graphics to create the illusion of "color depth" in images with
2123: a limited color palette - a technique also known as color quantization. In a dithered image,
2124: colors that are not available in the palette are approximated by a diffusion of colored pixels
2125: from within the available palette. The human eye perceives the diffusion as a mixture of
2126: the colors within it (see color vision). Dithered images, particularly those with relatively
2127: few colors, can often be distinguished by a characteristic graininess or speckled appearance
2128:
2129: Take a pygame surface as argument format 24-32 bit and convert it to a 3d array format
2130: (w, h, 3) type float (float32, single precision).
2131: As the image is converted to a different data type format (uint8 to float32),
2132: the transformation cannot be applied inplace. The image returned by the method dithering
2133: is a copy of the original image.
2134:
2135: :param surface_: Pygame surface format 24-32 bit
2136: :param factor_ : integer; Value must be > 1 otherwise an exception will be thrown
2137: :return : Surface;
2138:
2139: """
+2140: 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(1, 2140, __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(1, 2140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2141: 'Argument surface_ must be a pygame.Surface got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyga, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2141, __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(1, 2140, __pyx_L1_error) } } #endif
2142:
+2143: assert PyObject_IsInstance(factor_, int), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_factor_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_t_1, ((PyObject *)(&PyInt_Type))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 2143, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2144: 'Argument factor_ must be an int got %s ' % type(factor_)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_factor_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_factor__must_be_an_int, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2144, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 2143, __pyx_L1_error) } } #endif
2145:
+2146: assert factor_ > 1, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_factor_ > 1) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_factor__must_be_1); __PYX_ERR(1, 2146, __pyx_L1_error) } } #endif
2147: "Argument factor_ must be > 1"
2148:
+2149: return dithering_c(numpy.divide(pixels3d(surface_), 255.0).astype(float32), factor_)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_divide); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_8 = 0; 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_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_float_255_0}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_4, __pyx_float_255_0}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_t_4); __Pyx_INCREF(__pyx_float_255_0); __Pyx_GIVEREF(__pyx_float_255_0); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_float_255_0); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_float32); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_float(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __pyx_f_6shader_dithering_c(__pyx_t_9, __pyx_v_factor_); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
2150:
2151: @cython.binding(False)
2152: @cython.boundscheck(False)
2153: @cython.wraparound(False)
2154: @cython.nonecheck(False)
2155: @cython.cdivision(True)
+2156: cpdef inline void dithering_int(object surface_, int factor_=2):
static PyObject *__pyx_pw_6shader_105dithering_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_dithering_int(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_dithering_int *__pyx_optional_args) { int __pyx_v_factor_ = ((int)2); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering_int", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_factor_ = __pyx_optional_args->factor_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_WriteUnraisable("shader.dithering_int", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_105dithering_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_104dithering_int[] = "\n Dithering is used in computer graphics to create the illusion of \"color depth\" in images with\n a limited color palette - a technique also known as color quantization. In a dithered image,\n colors that are not available in the palette are approximated by a diffusion of colored pixels\n from within the available palette. The human eye perceives the diffusion as a mixture of \n the colors within it (see color vision). Dithered images, particularly those with relatively\n few colors, can often be distinguished by a characteristic graininess or speckled appearance\n\n Take a pygame surface as argument format 24-32 bit and convert it to a 3d array format \n (w, h, 3) type float (float32, single precision). \n As the image is converted to a different data type format (uint8 to float32), \n the transformation cannot be applied inplace. The image returned by the method dithering \n is a copy of the original image. \n\n :param surface_: Pygame surface format 24-32 bit \n :param factor_ : integer; Value must be > 1 otherwise an exception will be thrown \n :return : Surface; \n\n "; static PyObject *__pyx_pw_6shader_105dithering_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_factor_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering_int (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_factor,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_factor); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dithering_int") < 0)) __PYX_ERR(1, 2156, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_factor_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_factor_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2156, __pyx_L3_error) } else { __pyx_v_factor_ = ((int)2); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dithering_int", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2156, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.dithering_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_104dithering_int(__pyx_self, __pyx_v_surface_, __pyx_v_factor_); 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_6shader_104dithering_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_factor_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering_int", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.factor_ = __pyx_v_factor_; __pyx_f_6shader_dithering_int(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.dithering_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2157: """
2158: Dithering is used in computer graphics to create the illusion of "color depth" in images with
2159: a limited color palette - a technique also known as color quantization. In a dithered image,
2160: colors that are not available in the palette are approximated by a diffusion of colored pixels
2161: from within the available palette. The human eye perceives the diffusion as a mixture of
2162: the colors within it (see color vision). Dithered images, particularly those with relatively
2163: few colors, can often be distinguished by a characteristic graininess or speckled appearance
2164:
2165: Take a pygame surface as argument format 24-32 bit and convert it to a 3d array format
2166: (w, h, 3) type float (float32, single precision).
2167: As the image is converted to a different data type format (uint8 to float32),
2168: the transformation cannot be applied inplace. The image returned by the method dithering
2169: is a copy of the original image.
2170:
2171: :param surface_: Pygame surface format 24-32 bit
2172: :param factor_ : integer; Value must be > 1 otherwise an exception will be thrown
2173: :return : Surface;
2174:
2175: """
+2176: 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(1, 2176, __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(1, 2176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2177: 'Argument surface_ must be a pygame.Surface got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyga, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2177, __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(1, 2176, __pyx_L1_error) } } #endif
2178:
+2179: assert PyObject_IsInstance(factor_, int), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_factor_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_t_1, ((PyObject *)(&PyInt_Type))); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 2179, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2180: 'Argument factor_ must be an int got %s ' % type(factor_)
__pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_factor_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_factor__must_be_an_int, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 2179, __pyx_L1_error) } } #endif
2181:
+2182: assert factor_ > 1, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_factor_ > 1) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_factor__must_be_1); __PYX_ERR(1, 2182, __pyx_L1_error) } } #endif
2183: "Argument factor_ must be > 1"
2184:
+2185: dithering_int_c(pixels3d(surface_), factor_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_4, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 2185, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_f_6shader_dithering_int_c(__pyx_t_5, __pyx_v_factor_); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
2186:
2187: @cython.binding(False)
2188: @cython.boundscheck(False)
2189: @cython.wraparound(False)
2190: @cython.nonecheck(False)
2191: @cython.cdivision(True)
+2192: cpdef object pixelation(object surface_):
static PyObject *__pyx_pw_6shader_107pixelation(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static PyObject *__pyx_f_6shader_pixelation(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; PyObject *__pyx_v_small = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("pixelation", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("shader.pixelation", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_small); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_107pixelation(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_106pixelation[] = "\n Pixelate a pygame.Surface \n \n This method cannot be used for the game display as the change \n is applied in a new Surface\n \n :param surface_: pygame.Surface; \n :return: pixelated surface\n "; static PyObject *__pyx_pw_6shader_107pixelation(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("pixelation (wrapper)", 0); __pyx_r = __pyx_pf_6shader_106pixelation(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_106pixelation(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("pixelation", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_pixelation(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2192, __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("shader.pixelation", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2193: """
2194: Pixelate a pygame.Surface
2195:
2196: This method cannot be used for the game display as the change
2197: is applied in a new Surface
2198:
2199: :param surface_: pygame.Surface;
2200: :return: pixelated surface
2201: """
+2202: 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(1, 2202, __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(1, 2202, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2203: 'Argument surface_ must be a pygame.Surface got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyga, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2203, __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(1, 2202, __pyx_L1_error) } } #endif
2204:
2205: cdef Py_ssize_t w, h
2206: # todo percentage of pixelation
+2207: w, h = surface_.get_size()
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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(1, 2207, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(1, 2207, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 2207, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 2207, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_w = __pyx_t_7; __pyx_v_h = __pyx_t_8;
+2208: cdef object small = smoothscale(surface_, (32, 32))
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_surface_, __pyx_tuple__16}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2208, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_surface_, __pyx_tuple__16}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2208, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_surface_); __Pyx_GIVEREF(__pyx_v_surface_); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_surface_); __Pyx_INCREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_tuple__16); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_small = __pyx_t_1; __pyx_t_1 = 0; /* … */ __pyx_tuple__16 = PyTuple_Pack(2, __pyx_int_32, __pyx_int_32); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 2208, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16);
+2209: return scale(small, (w, h))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_scale); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3); __pyx_t_5 = 0; __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_small, __pyx_t_10}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_small, __pyx_t_10}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_small); __Pyx_GIVEREF(__pyx_v_small); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_small); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2210:
2211: @cython.binding(False)
2212: @cython.boundscheck(False)
2213: @cython.wraparound(False)
2214: @cython.nonecheck(False)
2215: @cython.cdivision(True)
+2216: cpdef inline zoom_in(object surface_):
static PyObject *__pyx_pw_6shader_109zoom_in(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_zoom_in(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("zoom_in", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.zoom_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_109zoom_in(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_108zoom_in[] = "\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return:\n "; static PyObject *__pyx_pw_6shader_109zoom_in(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("zoom_in (wrapper)", 0); __pyx_r = __pyx_pf_6shader_108zoom_in(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_108zoom_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("zoom_in", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_zoom_in(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2216, __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("shader.zoom_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2217: """
2218:
2219: :param surface_ : pygame.Surface; compatible 24 - 32 bit
2220: :return:
2221: """
+2222: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2222, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2223: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2222, __pyx_L1_error) } } #endif
2224:
+2225: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2225, __pyx_L1_error)
2226:
2227:
2228: @cython.binding(False)
2229: @cython.boundscheck(False)
2230: @cython.wraparound(False)
2231: @cython.nonecheck(False)
2232: @cython.cdivision(True)
+2233: cpdef inline electric(object surface_):
static PyObject *__pyx_pw_6shader_111electric(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_electric(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("electric", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.electric", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_111electric(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_110electric[] = "\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return:\n "; static PyObject *__pyx_pw_6shader_111electric(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("electric (wrapper)", 0); __pyx_r = __pyx_pf_6shader_110electric(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_110electric(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("electric", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_electric(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2233, __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("shader.electric", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2234: """
2235:
2236: :param surface_ : pygame.Surface; compatible 24 - 32 bit
2237: :return:
2238: """
+2239: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2239, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2239, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2240: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2239, __pyx_L1_error) } } #endif
2241:
+2242: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2242, __pyx_L1_error)
2243:
2244:
2245: @cython.binding(False)
2246: @cython.boundscheck(False)
2247: @cython.wraparound(False)
2248: @cython.nonecheck(False)
2249: @cython.cdivision(True)
+2250: cpdef inline filmstrips(object surface_):
static PyObject *__pyx_pw_6shader_113filmstrips(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE PyObject *__pyx_f_6shader_filmstrips(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("filmstrips", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.filmstrips", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_113filmstrips(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_112filmstrips[] = "\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return:\n "; static PyObject *__pyx_pw_6shader_113filmstrips(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("filmstrips (wrapper)", 0); __pyx_r = __pyx_pf_6shader_112filmstrips(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_112filmstrips(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("filmstrips", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_filmstrips(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2250, __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("shader.filmstrips", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2251: """
2252:
2253: :param surface_ : pygame.Surface; compatible 24 - 32 bit
2254: :return:
2255: """
+2256: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2256, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2257: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2256, __pyx_L1_error) } } #endif
2258:
+2259: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2259, __pyx_L1_error)
2260:
2261:
2262: @cython.binding(False)
2263: @cython.boundscheck(False)
2264: @cython.wraparound(False)
2265: @cython.nonecheck(False)
2266: @cython.cdivision(True)
+2267: cpdef cubism(object surface_):
static PyObject *__pyx_pw_6shader_115cubism(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static PyObject *__pyx_f_6shader_cubism(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cubism", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.cubism", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_115cubism(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_114cubism[] = "\n\n :param surface_ : pygame.Surface; compatible 24 - 32 bit \n :return:\n "; static PyObject *__pyx_pw_6shader_115cubism(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cubism (wrapper)", 0); __pyx_r = __pyx_pf_6shader_114cubism(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_114cubism(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cubism", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_cubism(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2267, __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("shader.cubism", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2268: """
2269:
2270: :param surface_ : pygame.Surface; compatible 24 - 32 bit
2271: :return:
2272: """
+2273: assert isinstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2273, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2274: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2273, __pyx_L1_error) } } #endif
+2275: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2275, __pyx_L1_error)
2276:
2277:
2278: @cython.binding(False)
2279: @cython.boundscheck(False)
2280: @cython.wraparound(False)
2281: @cython.nonecheck(False)
2282: @cython.cdivision(True)
+2283: cpdef code_listing(object surface_, size_):
static PyObject *__pyx_pw_6shader_117code_listing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_code_listing(PyObject *__pyx_v_surface_, CYTHON_UNUSED PyObject *__pyx_v_size_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("code_listing", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.code_listing", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_117code_listing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_116code_listing[] = "\n\n :param surface_: pygame.Surface; compatible 24 - 32 bit \n :param size_:\n :return:\n "; static PyObject *__pyx_pw_6shader_117code_listing(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; PyObject *__pyx_v_size_ = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("code_listing (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_size_2,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_size_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("code_listing", 1, 2, 2, 1); __PYX_ERR(1, 2283, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "code_listing") < 0)) __PYX_ERR(1, 2283, __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_size_ = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("code_listing", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2283, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.code_listing", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_116code_listing(__pyx_self, __pyx_v_surface_, __pyx_v_size_); 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_6shader_116code_listing(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, PyObject *__pyx_v_size_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("code_listing", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_code_listing(__pyx_v_surface_, __pyx_v_size_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2283, __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("shader.code_listing", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2284: """
2285:
2286: :param surface_: pygame.Surface; compatible 24 - 32 bit
2287: :param size_:
2288: :return:
2289: """
+2290: assert PyObject_IsInstance(surface_, pygame.Surface), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pygame); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 2290, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!(__pyx_t_3 != 0))) {
+2291: "\nArgument surface_ must be a pygame.Surface type, got %s " % type(surface_)
__pyx_t_2 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_pyg, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 2291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 2290, __pyx_L1_error) } } #endif
2292:
+2293: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2293, __pyx_L1_error)
2294:
2295: @cython.binding(False)
2296: @cython.boundscheck(False)
2297: @cython.wraparound(False)
2298: @cython.nonecheck(False)
2299: @cython.cdivision(True)
+2300: cpdef ascii_char(object surface_):
static PyObject *__pyx_pw_6shader_119ascii_char(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static PyObject *__pyx_f_6shader_ascii_char(CYTHON_UNUSED PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ascii_char", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("shader.ascii_char", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_119ascii_char(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_118ascii_char[] = "\n \n :param surface_: \n :return: \n "; static PyObject *__pyx_pw_6shader_119ascii_char(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ascii_char (wrapper)", 0); __pyx_r = __pyx_pf_6shader_118ascii_char(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_118ascii_char(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ascii_char", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_ascii_char(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2300, __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("shader.ascii_char", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2301: """
2302:
2303: :param surface_:
2304: :return:
2305: """
+2306: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2306, __pyx_L1_error)
2307:
2308: @cython.binding(False)
2309: @cython.boundscheck(False)
2310: @cython.wraparound(False)
2311: @cython.nonecheck(False)
2312: @cython.cdivision(True)
+2313: cpdef object blend(object source_, object destination_, float percentage_):
static PyObject *__pyx_pw_6shader_121blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_blend(PyObject *__pyx_v_source_, PyObject *__pyx_v_destination_, float __pyx_v_percentage_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blend", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("shader.blend", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_121blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_120blend[] = "\n BLEND A SOURCE TEXTURE TOWARD A DESTINATION TEXTURE \n \n The shader create a new image from both source_ and destination_\n\n * Video system must be initialised \n * source_ & destination_ Textures must be same sizes\n * Compatible with 24 - 32 bit surface\n * Output create a new surface\n * Image returned is converted for fast blit (convert())\n\n :param source_ : pygame.Surface (Source)\n :param destination_: pygame.Surface (Destination)\n :param percentage_ : float; Percentage value between [0.0 ... 100.0]\n :return: return : Return a 24 bit pygame.Surface and blended with a percentage\n of the destination texture.\n "; static PyObject *__pyx_pw_6shader_121blend(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_source_ = 0; PyObject *__pyx_v_destination_ = 0; float __pyx_v_percentage_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blend (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_source,&__pyx_n_s_destination,&__pyx_n_s_percentage,0}; PyObject* values[3] = {0,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 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_source)) != 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_destination)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("blend", 1, 3, 3, 1); __PYX_ERR(1, 2313, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_percentage)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("blend", 1, 3, 3, 2); __PYX_ERR(1, 2313, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blend") < 0)) __PYX_ERR(1, 2313, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_source_ = values[0]; __pyx_v_destination_ = values[1]; __pyx_v_percentage_ = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_percentage_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 2313, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("blend", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2313, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.blend", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_120blend(__pyx_self, __pyx_v_source_, __pyx_v_destination_, __pyx_v_percentage_); 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_6shader_120blend(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_source_, PyObject *__pyx_v_destination_, float __pyx_v_percentage_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blend", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_blend(__pyx_v_source_, __pyx_v_destination_, __pyx_v_percentage_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2313, __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("shader.blend", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2314: """
2315: BLEND A SOURCE TEXTURE TOWARD A DESTINATION TEXTURE
2316:
2317: The shader create a new image from both source_ and destination_
2318:
2319: * Video system must be initialised
2320: * source_ & destination_ Textures must be same sizes
2321: * Compatible with 24 - 32 bit surface
2322: * Output create a new surface
2323: * Image returned is converted for fast blit (convert())
2324:
2325: :param source_ : pygame.Surface (Source)
2326: :param destination_: pygame.Surface (Destination)
2327: :param percentage_ : float; Percentage value between [0.0 ... 100.0]
2328: :return: return : Return a 24 bit pygame.Surface and blended with a percentage
2329: of the destination texture.
2330: """
+2331: assert PyObject_IsInstance(source_, 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(1, 2331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_source_, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 2331, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2332: 'Argument source_ must be a pygame.Surface got %s ' % type(source_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_source__must_be_a_pygam, ((PyObject *)Py_TYPE(__pyx_v_source_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2332, __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(1, 2331, __pyx_L1_error) } } #endif
2333:
+2334: assert PyObject_IsInstance(destination_, 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(1, 2334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_destination_, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 2334, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2335: 'Argument destination_ must be a pygame.Surface got %s ' % type(destination_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_destination__must_be_a, ((PyObject *)Py_TYPE(__pyx_v_destination_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2335, __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(1, 2334, __pyx_L1_error) } } #endif
2336:
+2337: assert 0.0 <= percentage_ <= 100.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_2 = (0.0 <= __pyx_v_percentage_); if (__pyx_t_2) { __pyx_t_2 = (__pyx_v_percentage_ <= 100.0); } if (unlikely(!(__pyx_t_2 != 0))) {
+2338: "\nIncorrect value for argument percentage should be [0.0 ... 100.0] got %s " % percentage_
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_percentage_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Incorrect_value_for_argument_pe, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 2337, __pyx_L1_error) } } #endif
2339:
+2340: if percentage_ == 0.0:
__pyx_t_2 = ((__pyx_v_percentage_ == 0.0) != 0); if (__pyx_t_2) { /* … */ }
+2341: return source_
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_source_); __pyx_r = __pyx_v_source_; goto __pyx_L0;
2342:
+2343: assert source_.get_size() == destination_.get_size(), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_source_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_destination_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2343, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 2343, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) {
2344: 'Source and Destination surfaces must have same dimensions: ' \
+2345: 'Source (w:%s, h:%s), destination (w:%s, h:%s).' % \
__pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Source_and_Destination_surfaces, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 2343, __pyx_L1_error) } } #endif
+2346: (*source_.get_size(), *destination_.get_size())
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_source_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_destination_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__Pyx_PyList_Extend(__pyx_t_4, __pyx_t_1) < 0) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; { PyObject *__pyx_temp = PyList_AsTuple(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = __pyx_temp; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); }
2347:
+2348: return blending(source_, destination_, percentage_)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_blending(__pyx_v_source_, __pyx_v_destination_, __pyx_v_percentage_); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2349:
2350:
2351:
2352: @cython.binding(False)
2353: @cython.boundscheck(False)
2354: @cython.wraparound(False)
2355: @cython.nonecheck(False)
2356: @cython.cdivision(True)
+2357: cpdef cartoon(
static PyObject *__pyx_pw_6shader_123cartoon(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_cartoon(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_cartoon *__pyx_optional_args) { int __pyx_v_sobel_threshold_ = ((int)0x80); int __pyx_v_median_kernel_ = ((int)2); PyObject *__pyx_v_color_ = ((PyObject *)__pyx_int_8); PyObject *__pyx_v_flag_ = __pyx_k__17; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cartoon", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_sobel_threshold_ = __pyx_optional_args->sobel_threshold_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_median_kernel_ = __pyx_optional_args->median_kernel_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_color_ = __pyx_optional_args->color_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_flag_ = __pyx_optional_args->flag_; } } } } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("shader.cartoon", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_123cartoon(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_122cartoon[] = "\n CREATE A CARTOON EFFECT FROM A GIVEN SURFACE \n \n * This shader cannot be use online or real time due to the amout of \n transformation. You can use this shader while editing your textures \n befre the main loop \n \n * Compatible with 24 - 32 bit image \n \n :param surface_: pygame.Surface compatible 24 - 32 bit \n :param sobel_threshold_: integer sobel threshold\n :param median_kernel_ : integer median kernel \n :param color_ : integer; color reduction value (max color)\n :param flag_ : integer; Blend flag e.g (BLEND_RGB_ADD, BLEND_RGB_SUB, \n BLEND_RGB_MULT, BLEND_RGB_MAX, BLEND_RGB_MIN \n :return : Return a pygame Surface with the cartoon effect \n "; static PyObject *__pyx_pw_6shader_123cartoon(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_sobel_threshold_; int __pyx_v_median_kernel_; PyObject *__pyx_v_color_ = 0; PyObject *__pyx_v_flag_ = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cartoon (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_sobel_threshold_2,&__pyx_n_s_median_kernel,&__pyx_n_s_color,&__pyx_n_s_flag,0}; PyObject* values[5] = {0,0,0,0,0}; values[3] = ((PyObject *)__pyx_int_8); values[4] = __pyx_k__17; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_surface)) != 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_sobel_threshold_2); 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_median_kernel); 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_color); if (value) { values[3] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flag); if (value) { values[4] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cartoon") < 0)) __PYX_ERR(1, 2357, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_surface_ = values[0]; if (values[1]) { __pyx_v_sobel_threshold_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_sobel_threshold_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2359, __pyx_L3_error) } else { __pyx_v_sobel_threshold_ = ((int)0x80); } if (values[2]) { __pyx_v_median_kernel_ = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_median_kernel_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2360, __pyx_L3_error) } else { __pyx_v_median_kernel_ = ((int)2); } __pyx_v_color_ = values[3]; __pyx_v_flag_ = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cartoon", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2357, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.cartoon", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_122cartoon(__pyx_self, __pyx_v_surface_, __pyx_v_sobel_threshold_, __pyx_v_median_kernel_, __pyx_v_color_, __pyx_v_flag_); 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_6shader_122cartoon(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_sobel_threshold_, int __pyx_v_median_kernel_, PyObject *__pyx_v_color_, PyObject *__pyx_v_flag_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cartoon", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 4; __pyx_t_2.sobel_threshold_ = __pyx_v_sobel_threshold_; __pyx_t_2.median_kernel_ = __pyx_v_median_kernel_; __pyx_t_2.color_ = __pyx_v_color_; __pyx_t_2.flag_ = __pyx_v_flag_; __pyx_t_1 = __pyx_f_6shader_cartoon(__pyx_v_surface_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2357, __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("shader.cartoon", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2358: object surface_,
2359: int sobel_threshold_ = 128,
2360: int median_kernel_ = 2,
2361: color_ = 8,
+2362: flag_ = BLEND_RGB_ADD
__Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 2362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __pyx_k__17 = __pyx_t_33; __Pyx_GIVEREF(__pyx_t_33); __pyx_t_33 = 0; /* … */ __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 2362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __pyx_k__17 = __pyx_t_33; __Pyx_GIVEREF(__pyx_t_33); __pyx_t_33 = 0;
2363: ):
2364: """
2365: CREATE A CARTOON EFFECT FROM A GIVEN SURFACE
2366:
2367: * This shader cannot be use online or real time due to the amout of
2368: transformation. You can use this shader while editing your textures
2369: befre the main loop
2370:
2371: * Compatible with 24 - 32 bit image
2372:
2373: :param surface_: pygame.Surface compatible 24 - 32 bit
2374: :param sobel_threshold_: integer sobel threshold
2375: :param median_kernel_ : integer median kernel
2376: :param color_ : integer; color reduction value (max color)
2377: :param flag_ : integer; Blend flag e.g (BLEND_RGB_ADD, BLEND_RGB_SUB,
2378: BLEND_RGB_MULT, BLEND_RGB_MAX, BLEND_RGB_MIN
2379: :return : Return a pygame Surface with the cartoon effect
2380: """
2381:
+2382: return cartoon_effect(surface_, sobel_threshold_, median_kernel_, color_, flag_)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_color_); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2382, __pyx_L1_error) __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_flag_); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2382, __pyx_L1_error) __pyx_t_3 = __pyx_f_6shader_cartoon_effect(__pyx_v_surface_, __pyx_v_sobel_threshold_, __pyx_v_median_kernel_, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
2383:
2384:
2385: @cython.binding(False)
2386: @cython.boundscheck(False)
2387: @cython.wraparound(False)
2388: @cython.nonecheck(False)
2389: @cython.cdivision(True)
+2390: cpdef explode(object surface_):
static PyObject *__pyx_pw_6shader_125explode(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static PyObject *__pyx_f_6shader_explode(CYTHON_UNUSED PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("explode", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("shader.explode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_125explode(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_124explode[] = "\n\n :param surface_: \n :return: \n "; static PyObject *__pyx_pw_6shader_125explode(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("explode (wrapper)", 0); __pyx_r = __pyx_pf_6shader_124explode(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_124explode(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("explode", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_explode(__pyx_v_surface_, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2390, __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("shader.explode", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2391: """
2392:
2393: :param surface_:
2394: :return:
2395: """
+2396: raise NotImplementedError
__Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(1, 2396, __pyx_L1_error)
2397:
2398: @cython.binding(False)
2399: @cython.boundscheck(False)
2400: @cython.wraparound(False)
2401: @cython.nonecheck(False)
2402: @cython.cdivision(True)
+2403: cpdef object spectrum(int width, int height, float gamma=1.0):
static PyObject *__pyx_pw_6shader_127spectrum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_spectrum(int __pyx_v_width, int __pyx_v_height, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_spectrum *__pyx_optional_args) { float __pyx_v_gamma = ((float)1.0); PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("spectrum", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_gamma = __pyx_optional_args->gamma; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("shader.spectrum", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_127spectrum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_126spectrum[] = "\n CREATE A PYGAME SURFACE DISPLAYING THE LIGHT SPECTRUM 380-750 nm\n\n Color Wavelength(nm) Frequency(THz)\n Red 620-750 484-400\n Orange 590-620 508-484\n Yellow 570-590 526-508\n Green 495-570 606-526\n Blue 450-495 668-606\n Violet 380-450 789-668\n\n :param width: integer; width of the image\n :param height: integer; height of the image\n :param gamma: float; gamma value \n :return: Return a pygame surface 24-bit (width, height) converted for fast \n blit \n\n "; static PyObject *__pyx_pw_6shader_127spectrum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_width; int __pyx_v_height; float __pyx_v_gamma; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("spectrum (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_gamma,0}; PyObject* values[3] = {0,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 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("spectrum", 0, 2, 3, 1); __PYX_ERR(1, 2403, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gamma); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "spectrum") < 0)) __PYX_ERR(1, 2403, __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); 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(1, 2403, __pyx_L3_error) __pyx_v_height = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2403, __pyx_L3_error) if (values[2]) { __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 2403, __pyx_L3_error) } else { __pyx_v_gamma = ((float)1.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("spectrum", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2403, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.spectrum", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_126spectrum(__pyx_self, __pyx_v_width, __pyx_v_height, __pyx_v_gamma); 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_6shader_126spectrum(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_width, int __pyx_v_height, float __pyx_v_gamma) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("spectrum", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.gamma = __pyx_v_gamma; __pyx_t_1 = __pyx_f_6shader_spectrum(__pyx_v_width, __pyx_v_height, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2403, __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("shader.spectrum", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2404: """
2405: CREATE A PYGAME SURFACE DISPLAYING THE LIGHT SPECTRUM 380-750 nm
2406:
2407: Color Wavelength(nm) Frequency(THz)
2408: Red 620-750 484-400
2409: Orange 590-620 508-484
2410: Yellow 570-590 526-508
2411: Green 495-570 606-526
2412: Blue 450-495 668-606
2413: Violet 380-450 789-668
2414:
2415: :param width: integer; width of the image
2416: :param height: integer; height of the image
2417: :param gamma: float; gamma value
2418: :return: Return a pygame surface 24-bit (width, height) converted for fast
2419: blit
2420:
2421: """
2422:
+2423: return spectrum_c(width, height, gamma)
__Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.gamma = __pyx_v_gamma; __pyx_t_1 = __pyx_f_6shader_spectrum_c(__pyx_v_width, __pyx_v_height, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2424:
2425:
2426: @cython.boundscheck(False)
2427: @cython.wraparound(False)
2428: @cython.nonecheck(False)
2429: @cython.cdivision(True)
+2430: cpdef inline void convert_27colors(object surface_):
static PyObject *__pyx_pw_6shader_129convert_27colors(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_convert_27colors(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_array_ = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_27colors", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_WriteUnraisable("shader.convert_27colors", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_array_); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_129convert_27colors(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_128convert_27colors[] = "\n THIS ALGORITHM CONVERT AN IMAGE USING 27 COLORS ONLY\n\n :param surface_: numpy.ndarray; containing the pixels RGB. Array shape (w, h, 3) \n :return: void \n "; static PyObject *__pyx_pw_6shader_129convert_27colors(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_27colors (wrapper)", 0); __pyx_r = __pyx_pf_6shader_128convert_27colors(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_128convert_27colors(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_27colors", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_convert_27colors(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2430, __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("shader.convert_27colors", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2431:
2432: """
2433: THIS ALGORITHM CONVERT AN IMAGE USING 27 COLORS ONLY
2434:
2435: :param surface_: numpy.ndarray; containing the pixels RGB. Array shape (w, h, 3)
2436: :return: void
2437: """
+2438: assert 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(1, 2438, __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(1, 2438, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2439: 'Argument surface_ must be a valid Surface, got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_vali, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2439, __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(1, 2438, __pyx_L1_error) } } #endif
2440:
+2441: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L8_try_end:; }
+2442: array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2442, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2442, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_array_ = __pyx_t_1; __pyx_t_1 = 0;
2443:
+2444: except (pygame.error, ValueError):
__Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pygame); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2444, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2444, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_9) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_ValueError); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ErrRestore(__pyx_t_1, __pyx_t_6, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; if (__pyx_t_10) { __Pyx_AddTraceback("shader.convert_27colors", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_1) < 0) __PYX_ERR(1, 2444, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_1);
+2445: raise ValueError('\nTexture/image is not compatible.')
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2445, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(1, 2445, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:; /* … */ __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Texture_image_is_not_compatible); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 2445, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18);
2446:
+2447: convert_27colors_c(array_)
__pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2447, __pyx_L1_error) __pyx_f_6shader_convert_27colors_c(__pyx_t_11); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
2448:
2449:
2450:
2451: @cython.boundscheck(False)
2452: @cython.wraparound(False)
2453: @cython.nonecheck(False)
2454: @cython.cdivision(True)
+2455: cpdef object bilateral(object image, float sigma_s, float sigma_i):
static PyObject *__pyx_pw_6shader_131bilateral(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_bilateral(PyObject *__pyx_v_image, float __pyx_v_sigma_s, float __pyx_v_sigma_i, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_array_ = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bilateral", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_AddTraceback("shader.bilateral", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_array_); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_131bilateral(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_130bilateral[] = "\n A bilateral filter is a non-linear, edge-preserving, and noise-reducing\n smoothing filter for images. It replaces the intensity of each pixel with a\n weighted average of intensity values from nearby pixels. This weight can be\n based on a Gaussian distribution.\n\n Here, the normalization factor and the range weight are new terms added to \n the previous equation. sigma_s denotes the spatial extent of the kernel, i.e. \n the size of the neighborhood, and sigma_r denotes the minimum amplitude of an edge.\n It ensures that only those pixels with intensity values similar to that of the\n central pixel are considered for blurring, while sharp intensity changes are maintained.\n The smaller the value of sigma_i ( or sigma_r), the sharper the edge. As sigma_r tends to \n infinity, the equation tends to a Gaussian blur.\n \n e.g:\n \n bilateral(surface, sigma_s = 16, sigma_i = 18)\n \n :param image: Surface, Pygame Surface format 24-32 bit format (alpha channel will be ignored)\n \n :param sigma_s: float sigma_s : Spatial extent of the kernel, size of the \n considered neighborhood\n \n :param sigma_i: float sigma_i (also call sigma_r) range kernel, minimum amplitude of an edge.\n \n :return: return a filtered Surface\n "; static PyObject *__pyx_pw_6shader_131bilateral(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_image = 0; float __pyx_v_sigma_s; float __pyx_v_sigma_i; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bilateral (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_image,&__pyx_n_s_sigma_s,&__pyx_n_s_sigma_i,0}; PyObject* values[3] = {0,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 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_image)) != 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_sigma_s)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("bilateral", 1, 3, 3, 1); __PYX_ERR(1, 2455, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sigma_i)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("bilateral", 1, 3, 3, 2); __PYX_ERR(1, 2455, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "bilateral") < 0)) __PYX_ERR(1, 2455, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_image = values[0]; __pyx_v_sigma_s = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_sigma_s == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 2455, __pyx_L3_error) __pyx_v_sigma_i = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_sigma_i == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 2455, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("bilateral", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2455, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.bilateral", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_130bilateral(__pyx_self, __pyx_v_image, __pyx_v_sigma_s, __pyx_v_sigma_i); 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_6shader_130bilateral(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_image, float __pyx_v_sigma_s, float __pyx_v_sigma_i) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bilateral", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_bilateral(__pyx_v_image, __pyx_v_sigma_s, __pyx_v_sigma_i, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2455, __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("shader.bilateral", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2456: """
2457: A bilateral filter is a non-linear, edge-preserving, and noise-reducing
2458: smoothing filter for images. It replaces the intensity of each pixel with a
2459: weighted average of intensity values from nearby pixels. This weight can be
2460: based on a Gaussian distribution.
2461:
2462: Here, the normalization factor and the range weight are new terms added to
2463: the previous equation. sigma_s denotes the spatial extent of the kernel, i.e.
2464: the size of the neighborhood, and sigma_r denotes the minimum amplitude of an edge.
2465: It ensures that only those pixels with intensity values similar to that of the
2466: central pixel are considered for blurring, while sharp intensity changes are maintained.
2467: The smaller the value of sigma_i ( or sigma_r), the sharper the edge. As sigma_r tends to
2468: infinity, the equation tends to a Gaussian blur.
2469:
2470: e.g:
2471:
2472: bilateral(surface, sigma_s = 16, sigma_i = 18)
2473:
2474: :param image: Surface, Pygame Surface format 24-32 bit format (alpha channel will be ignored)
2475:
2476: :param sigma_s: float sigma_s : Spatial extent of the kernel, size of the
2477: considered neighborhood
2478:
2479: :param sigma_i: float sigma_i (also call sigma_r) range kernel, minimum amplitude of an edge.
2480:
2481: :return: return a filtered Surface
2482: """
2483:
+2484: assert isinstance(image, 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(1, 2484, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_IsInstance(__pyx_v_image, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 2484, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2485: 'Argument image must be a valid Surface, got %s ' % type(image)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_image_must_be_a_valid_S, ((PyObject *)Py_TYPE(__pyx_v_image))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2485, __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(1, 2484, __pyx_L1_error) } } #endif
2486:
+2487: assert isinstance(sigma_s, float), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = PyFloat_FromDouble(__pyx_v_sigma_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyFloat_Check(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2488: 'Argument sigma_s must be a valid Surface, got %s ' % type(sigma_s)
__pyx_t_1 = PyFloat_FromDouble(__pyx_v_sigma_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_sigma_s_must_be_a_valid, ((PyObject *)Py_TYPE(__pyx_t_1))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 2487, __pyx_L1_error) } } #endif
2489:
+2490: assert isinstance(sigma_i, float), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_3 = PyFloat_FromDouble(__pyx_v_sigma_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyFloat_Check(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2491: 'Argument sigma_i must be a valid Surface, got %s ' % type(sigma_i)
__pyx_t_3 = PyFloat_FromDouble(__pyx_v_sigma_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_sigma_i_must_be_a_valid, ((PyObject *)Py_TYPE(__pyx_t_3))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(1, 2490, __pyx_L1_error) } } #endif
2492:
+2493: try:
{ /*try:*/ { /* … */ } __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; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L8_try_end:; }
+2494: array_ = pixels3d(image)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2494, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_v_image) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_image); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2494, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_array_ = __pyx_t_1; __pyx_t_1 = 0;
2495:
+2496: except (pygame.error, ValueError):
__Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_3, &__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pygame); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2496, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2496, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_9) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_ValueError); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_7 = 0; if (__pyx_t_10) { __Pyx_AddTraceback("shader.bilateral", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(1, 2496, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_1);
+2497: raise ValueError('\nTexture/image is not compatible.')
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2497, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(1, 2497, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:;
2498:
2499:
+2500: return bilateral_filter24_c(array_, sigma_s, sigma_i)
__Pyx_XDECREF(__pyx_r); __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2500, __pyx_L1_error) __pyx_t_1 = __pyx_f_6shader_bilateral_filter24_c(__pyx_t_11, __pyx_v_sigma_s, __pyx_v_sigma_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2501:
2502: @cython.boundscheck(False)
2503: @cython.wraparound(False)
2504: @cython.nonecheck(False)
2505: @cython.cdivision(True)
+2506: cpdef object emboss(object surface_, unsigned int flag=0):
static PyObject *__pyx_pw_6shader_133emboss(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_emboss(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_emboss *__pyx_optional_args) { unsigned int __pyx_v_flag = ((unsigned int)0); PyObject *__pyx_v_array_ = NULL; PyObject *__pyx_v_emb = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("emboss", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_flag = __pyx_optional_args->flag; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_AddTraceback("shader.emboss", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_array_); __Pyx_XDECREF(__pyx_v_emb); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_133emboss(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_132emboss[] = "\n EMBOSS A PYGAME SURFACE \n \n :param surface_: pygame.Surface; compatible 24-32 bit\n :param flag : integer; special pygame flag such as BLEND_RGB_ADD, BLEND_RGB_MULT etc\n :return : void\n "; static PyObject *__pyx_pw_6shader_133emboss(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; unsigned int __pyx_v_flag; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("emboss (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_flag_2,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flag_2); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "emboss") < 0)) __PYX_ERR(1, 2506, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_flag = __Pyx_PyInt_As_unsigned_int(values[1]); if (unlikely((__pyx_v_flag == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 2506, __pyx_L3_error) } else { __pyx_v_flag = ((unsigned int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("emboss", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2506, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.emboss", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_132emboss(__pyx_self, __pyx_v_surface_, __pyx_v_flag); 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_6shader_132emboss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, unsigned int __pyx_v_flag) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("emboss", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.flag = __pyx_v_flag; __pyx_t_1 = __pyx_f_6shader_emboss(__pyx_v_surface_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2506, __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("shader.emboss", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2507: """
2508: EMBOSS A PYGAME SURFACE
2509:
2510: :param surface_: pygame.Surface; compatible 24-32 bit
2511: :param flag : integer; special pygame flag such as BLEND_RGB_ADD, BLEND_RGB_MULT etc
2512: :return : void
2513: """
2514:
+2515: assert 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(1, 2515, __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(1, 2515, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2516: 'Argument surface_ must be a valid Surface, got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_vali, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2516, __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(1, 2515, __pyx_L1_error) } } #endif
2517:
+2518: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L8_try_end:; }
+2519: array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2519, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2519, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_array_ = __pyx_t_1; __pyx_t_1 = 0;
2520:
+2521: except (pygame.error, ValueError):
__Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pygame); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2521, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2521, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_9) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_builtin_ValueError); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ErrRestore(__pyx_t_1, __pyx_t_6, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; if (__pyx_t_10) { __Pyx_AddTraceback("shader.emboss", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_1) < 0) __PYX_ERR(1, 2521, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_1);
+2522: raise ValueError('\nTexture/image is not compatible.')
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2522, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(1, 2522, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:;
2523:
+2524: cdef object emb = emboss5x5_c(array_)
__pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2524, __pyx_L1_error) __pyx_t_1 = __pyx_f_6shader_emboss5x5_c(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL; __pyx_v_emb = __pyx_t_1; __pyx_t_1 = 0;
2525:
+2526: if flag != 0:
__pyx_t_2 = ((__pyx_v_flag != 0) != 0); if (__pyx_t_2) { /* … */ }
+2527: del array_
__Pyx_DECREF(__pyx_v_array_);
__pyx_v_array_ = NULL;
+2528: surface_.blit(emb, (0, 0), special_flags=flag)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_emb); __Pyx_GIVEREF(__pyx_v_emb); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_emb); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_tuple__12); __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyInt_From_unsigned_int(__pyx_v_flag); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_special_flags, __pyx_t_9) < 0) __PYX_ERR(1, 2528, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2529: return surface_
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_surface_); __pyx_r = __pyx_v_surface_; goto __pyx_L0;
2530:
+2531: return emboss5x5_c(array_)
__Pyx_XDECREF(__pyx_r); __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2531, __pyx_L1_error) __pyx_t_9 = __pyx_f_6shader_emboss5x5_c(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0;
2532:
2533:
2534:
2535:
2536: @cython.binding(False)
2537: @cython.boundscheck(False)
2538: @cython.wraparound(False)
2539: @cython.nonecheck(False)
2540: @cython.cdivision(True)
+2541: cpdef void palette_change(
static PyObject *__pyx_pw_6shader_135palette_change(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static void __pyx_f_6shader_palette_change(PyObject *__pyx_v_surface_, PyObject *__pyx_v_palette_, CYTHON_UNUSED int __pyx_skip_dispatch) { PyObject *__pyx_v_array_ = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("palette_change", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1); __Pyx_WriteUnraisable("shader.palette_change", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_array_); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_135palette_change(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_134palette_change[] = "\n CHANGE AN IMAGE BY CHANGING THE COLOR PALETTE \n \n LIST_PALETTES contains all the palettes available\n in the project.\n \n e.g: \n from PygameShader.Palette import LIST_PALETTES\n print(LIST_PALETTES.keys())\n \n :param surface_: pygame.Surface; \n :param palette_: numpy.ndarray containing all the RGB color values \n :return: void\n "; static PyObject *__pyx_pw_6shader_135palette_change(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; PyObject *__pyx_v_palette_ = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("palette_change (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_palette,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_palette)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("palette_change", 1, 2, 2, 1); __PYX_ERR(1, 2541, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "palette_change") < 0)) __PYX_ERR(1, 2541, __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_palette_ = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("palette_change", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 2541, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.palette_change", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_134palette_change(__pyx_self, __pyx_v_surface_, __pyx_v_palette_); 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_6shader_134palette_change(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, PyObject *__pyx_v_palette_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("palette_change", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_palette_change(__pyx_v_surface_, __pyx_v_palette_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2541, __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("shader.palette_change", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
2542: object surface_,
2543: object palette_):
2544: """
2545: CHANGE AN IMAGE BY CHANGING THE COLOR PALETTE
2546:
2547: LIST_PALETTES contains all the palettes available
2548: in the project.
2549:
2550: e.g:
2551: from PygameShader.Palette import LIST_PALETTES
2552: print(LIST_PALETTES.keys())
2553:
2554: :param surface_: pygame.Surface;
2555: :param palette_: numpy.ndarray containing all the RGB color values
2556: :return: void
2557: """
2558:
+2559: assert 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(1, 2559, __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(1, 2559, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2560: 'Argument surface_ must be a valid Surface, got %s ' % type(surface_)
__pyx_t_1 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_vali, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2560, __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(1, 2559, __pyx_L1_error) } } #endif
2561:
+2562: assert isinstance(palette_, numpy.ndarray), \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = PyObject_IsInstance(__pyx_v_palette_, __pyx_t_3); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(1, 2562, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!(__pyx_t_2 != 0))) {
+2563: 'Argument surface_ must be a valid Surface, got %s ' % type(palette_)
__pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_vali, ((PyObject *)Py_TYPE(__pyx_v_palette_))); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 2562, __pyx_L1_error) } } #endif
+2564: try:
{ /*try:*/ { /* … */ } __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; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L8_try_end:; }
+2565: array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2565, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_7, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 2565, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_array_ = __pyx_t_3; __pyx_t_3 = 0;
2566:
+2567: except (pygame.error, ValueError):
__Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_1, &__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pygame); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2567, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2567, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_9) || __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_builtin_ValueError); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ErrRestore(__pyx_t_3, __pyx_t_1, __pyx_t_7); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_7 = 0; if (__pyx_t_10) { __Pyx_AddTraceback("shader.palette_change", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(1, 2567, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_t_3);
+2568: raise ValueError('\nTexture/image is not compatible.')
__pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2568, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(1, 2568, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:;
2569:
+2570: palette_change_c(array_, palette_)
__pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2570, __pyx_L1_error) __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_v_palette_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(1, 2570, __pyx_L1_error) __pyx_f_6shader_palette_change_c(__pyx_t_11, __pyx_t_12); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL; __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1); __pyx_t_12.memview = NULL; __pyx_t_12.data = NULL;
2571:
2572: # ******************************************************************
2573:
2574:
2575:
2576: @cython.boundscheck(False)
2577: @cython.wraparound(False)
2578: @cython.nonecheck(False)
2579: @cython.cdivision(True)
+2580: cdef inline float damped_oscillation(float t)nogil:
static CYTHON_INLINE float __pyx_f_6shader_damped_oscillation(float __pyx_v_t) { float __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; }
2581: """
2582:
2583: :param t:
2584: :return:
2585: """
+2586: return <float>(exp(-t * 0.1) * <float>cos(M_PI * t))
__pyx_r = ((float)(exp(((-__pyx_v_t) * 0.1)) * ((float)cos((__pyx_v_6shader_M_PI * __pyx_v_t))))); goto __pyx_L0;
2587:
2588:
+2589: cdef float C1_ = <float>1.0 / <float>sqrt(M_2PI)
__pyx_v_6shader_C1_ = (((float)1.0) / ((float)sqrt(__pyx_v_6shader_M_2PI)));
2590:
+2591: cdef inline float gauss(float x, float c, float sigma=1.0, float mu=0.0)nogil:
static CYTHON_INLINE float __pyx_f_6shader_gauss(float __pyx_v_x, float __pyx_v_c, struct __pyx_opt_args_6shader_gauss *__pyx_optional_args) { float __pyx_v_sigma = ((float)1.0); float __pyx_v_mu = ((float)0.0); float __pyx_r; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_sigma = __pyx_optional_args->sigma; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_mu = __pyx_optional_args->mu; } } } /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_gauss { int __pyx_n; float sigma; float mu; };
2592: """
2593:
2594: :param x:
2595: :param c:
2596: :param sigma:
2597: :param mu:
2598: :return:
2599: """
+2600: x -= c
__pyx_v_x = (__pyx_v_x - __pyx_v_c);
+2601: return (1.0 / sigma * C1_) * exp(-0.5 * ((x - mu) * (x - mu)) / (sigma * sigma))
__pyx_r = (((1.0 / __pyx_v_sigma) * __pyx_v_6shader_C1_) * exp(((-0.5 * ((__pyx_v_x - __pyx_v_mu) * (__pyx_v_x - __pyx_v_mu))) / (__pyx_v_sigma * __pyx_v_sigma)))); goto __pyx_L0;
2602:
2603:
2604: @cython.boundscheck(False)
2605: @cython.wraparound(False)
2606: @cython.nonecheck(False)
2607: @cython.cdivision(True)
+2608: cdef inline void shader_rgb_to_bgr_inplace_c(unsigned char [:, :, :] rgb_array):
static CYTHON_INLINE void __pyx_f_6shader_shader_rgb_to_bgr_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; unsigned char __pyx_v_tmp; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_rgb_to_bgr_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
2609: """
2610: SHADER RGB to BGR
2611:
2612: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
2613: please refer to pygame function pixels3d or array3d to convert an image into a
2614: 3d array (library surfarray)
2615:
2616: Convert your game display from RGB to BGR format
2617: This algorithm can also be used to transform pygame texture in the equivalent bgr format
2618:
2619: e.g:
2620: rgb_to_bgr(surface)
2621:
2622: :param rgb_array : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
2623: pygame display pixels format RGB. Apply the transformation inplace by swapping the channel
2624: Red to channel blue and vice versa
2625: :return : void
2626: """
2627:
2628: cdef Py_ssize_t w, h
+2629: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
2630:
2631: cdef:
+2632: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
2633: unsigned char tmp
2634:
+2635: 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:; } }
2636:
+2637: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_tmp) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_tmp) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_i = ((int)0xbad0bad0); __pyx_v_tmp = ((unsigned char)'?');
+2638: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
+2639: tmp = rgb_array[i, j, 0] # keep the blue color
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_tmp = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) )));
+2640: rgb_array[i, j, 0] = rgb_array[i, j, 2]
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 2; __pyx_t_11 = __pyx_v_i; __pyx_t_12 = __pyx_v_j; __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_11 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_12 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) )));
+2641: rgb_array[i, j, 2] = tmp
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) )) = __pyx_v_tmp; } } } } } } #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 }
2642:
2643:
2644: @cython.boundscheck(False)
2645: @cython.wraparound(False)
2646: @cython.nonecheck(False)
2647: @cython.cdivision(True)
+2648: cdef inline void shader_rgb_to_brg_inplace_c(unsigned char [:, :, :] rgb_array):
static CYTHON_INLINE void __pyx_f_6shader_shader_rgb_to_brg_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; unsigned char __pyx_v_tmp_r; unsigned char __pyx_v_tmp_g; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_rgb_to_brg_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
2649: """
2650:
2651: SHADER RGB TO BRG
2652:
2653: Convert your game display from RGB to BRG format.
2654: This algorithm can also be used to transform pygame texture in the equivalent BRG format
2655:
2656: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
2657: please refer to pygame function pixels3d or array3d to convert an image into a 3d array
2658: (library surfarray)
2659:
2660: e.g:
2661: rgb_to_brg(surface)
2662:
2663: :param rgb_array : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
2664: pygame display pixels format RGB
2665: :return : void
2666: """
2667:
2668: cdef Py_ssize_t w, h
+2669: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
2670:
2671: cdef:
+2672: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
2673: unsigned char tmp_r, tmp_g
2674: unsigned char *r
2675: unsigned char *g
2676: unsigned char *b
2677:
+2678: 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:; } }
2679:
+2680: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_tmp_g) lastprivate(__pyx_v_tmp_r) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_tmp_g) lastprivate(__pyx_v_tmp_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_i = ((int)0xbad0bad0); __pyx_v_tmp_g = ((unsigned char)'?'); __pyx_v_tmp_r = ((unsigned char)'?');
+2681: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
+2682: tmp_r = rgb_array[i, j, 0] # keep the red color
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_tmp_r = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) )));
+2683: tmp_g = rgb_array[i, j, 1] # keep the green color
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_v_tmp_g = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) )));
+2684: rgb_array[i, j, 0] = rgb_array[i, j, 2] # r-->b
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_t_11 = __pyx_v_i; __pyx_t_12 = __pyx_v_j; __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_11 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_12 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) )));
+2685: rgb_array[i, j, 1] = tmp_r # g --> r
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) )) = __pyx_v_tmp_r;
+2686: rgb_array[i, j, 2] = tmp_g
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) )) = __pyx_v_tmp_g; } } } } } } #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 }
2687:
2688:
2689:
2690: @cython.boundscheck(False)
2691: @cython.wraparound(False)
2692: @cython.nonecheck(False)
2693: @cython.cdivision(True)
+2694: cdef inline void shader_greyscale_luminosity24_inplace_c(unsigned char [:, :, :] rgb_array):
static CYTHON_INLINE void __pyx_f_6shader_shader_greyscale_luminosity24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; unsigned char __pyx_v_luminosity; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_greyscale_luminosity24_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
2695: """
2696: SHADER GRAYSCALE (CONSERVE LUMINOSITY)
2697:
2698: This shader transform the game display on a grayscale video game effect
2699: This shader can also be applied to pygame textures/surface to transform them into
2700: an equivalent grayscale model
2701:
2702: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
2703: please refer to pygame function pixels3d or array3d to convert an image into a 3d array
2704: (library surfarray)
2705:
2706: e.g:
2707: greyscale(surface)
2708:
2709: :param rgb_array : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
2710: pygame display pixels format RGB
2711: :return : void
2712: """
2713:
2714: cdef Py_ssize_t w, h
+2715: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
2716:
2717: cdef:
2718: int i, j
2719: unsigned char luminosity
2720: unsigned char *r
2721: unsigned char *g
2722: unsigned char *b
2723:
+2724: 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:; } }
+2725: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_luminosity) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_luminosity) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_luminosity = ((unsigned char)'?'); __pyx_v_r = ((unsigned char *)1);
+2726: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
+2727: r = &rgb_array[i, j, 0]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+2728: g = &rgb_array[i, j, 1]
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+2729: b = &rgb_array[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+2730: luminosity = <unsigned char>(r[0] * 0.2126 + g[0] * 0.7152 + b[0] * 0.072)
__pyx_v_luminosity = ((unsigned char)((((__pyx_v_r[0]) * 0.2126) + ((__pyx_v_g[0]) * 0.7152)) + ((__pyx_v_b[0]) * 0.072)));
+2731: r[0] = luminosity
(__pyx_v_r[0]) = __pyx_v_luminosity;
+2732: g[0] = luminosity
(__pyx_v_g[0]) = __pyx_v_luminosity;
+2733: b[0] = luminosity
(__pyx_v_b[0]) = __pyx_v_luminosity; } } } } } } #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 }
2734:
2735:
2736: @cython.boundscheck(False)
2737: @cython.wraparound(False)
2738: @cython.nonecheck(False)
2739: @cython.cdivision(True)
+2740: cdef inline void shader_sepia24_inplace_c(unsigned char [:, :, :] rgb_array):
static CYTHON_INLINE void __pyx_f_6shader_shader_sepia24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; float __pyx_v_rr; float __pyx_v_gg; float __pyx_v_bb; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_sepia24_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
2741:
2742: """
2743: SHADER SEPIA MODEL
2744:
2745: Transform your video game into an equivalent sepia model
2746: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
2747: please refer to pygame function pixels3d or array3d to convert an image into a 3d array
2748: (library surfarray)
2749:
2750: e.g:
2751: sepia(surface)
2752:
2753: :param rgb_array : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
2754: pygame display pixels format RGB
2755: :return : void
2756: """
2757: cdef Py_ssize_t w, h
+2758: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
2759:
2760: cdef:
+2761: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
2762: float rr, gg, bb
2763: unsigned char *r
2764: unsigned char *g
2765: unsigned char *b
2766:
+2767: 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:; } }
+2768: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_bb = ((float)__PYX_NAN()); __pyx_v_g = ((unsigned char *)1); __pyx_v_gg = ((float)__PYX_NAN()); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_rr = ((float)__PYX_NAN());
+2769: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
2770:
+2771: r = &rgb_array[i, j, 0]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+2772: g = &rgb_array[i, j, 1]
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+2773: b = &rgb_array[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
2774:
+2775: rr = r[0] * <float>0.393 + g[0] * <float>0.769 + b[0] * <float>0.189
__pyx_v_rr = ((((__pyx_v_r[0]) * ((float)0.393)) + ((__pyx_v_g[0]) * ((float)0.769))) + ((__pyx_v_b[0]) * ((float)0.189)));
+2776: gg = r[0] * <float>0.349 + g[0] * <float>0.686 + b[0] * <float>0.168
__pyx_v_gg = ((((__pyx_v_r[0]) * ((float)0.349)) + ((__pyx_v_g[0]) * ((float)0.686))) + ((__pyx_v_b[0]) * ((float)0.168)));
+2777: bb = r[0] * <float>0.272 + g[0] * <float>0.534 + b[0] * <float>0.131
__pyx_v_bb = ((((__pyx_v_r[0]) * ((float)0.272)) + ((__pyx_v_g[0]) * ((float)0.534))) + ((__pyx_v_b[0]) * ((float)0.131)));
+2778: if rr > 255:
__pyx_t_11 = ((__pyx_v_rr > 255.0) != 0); if (__pyx_t_11) { /* … */ }
+2779: rr = 255
__pyx_v_rr = 255.0;
+2780: if gg > 255:
__pyx_t_11 = ((__pyx_v_gg > 255.0) != 0); if (__pyx_t_11) { /* … */ }
+2781: gg = 255
__pyx_v_gg = 255.0;
+2782: if bb > 255:
__pyx_t_11 = ((__pyx_v_bb > 255.0) != 0); if (__pyx_t_11) { /* … */ }
+2783: bb = 255
__pyx_v_bb = 255.0;
+2784: r[0] = <unsigned char> rr
(__pyx_v_r[0]) = ((unsigned char)__pyx_v_rr);
+2785: g[0] = <unsigned char> gg
(__pyx_v_g[0]) = ((unsigned char)__pyx_v_gg);
+2786: b[0] = <unsigned char> bb
(__pyx_v_b[0]) = ((unsigned char)__pyx_v_bb); } } } } } } #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 }
2787:
2788: # ************* SORTING ALGORITHM FOR MEDIAN FILTER
2789: @cython.boundscheck(False)
2790: @cython.wraparound(False)
2791: @cython.nonecheck(False)
2792: @cython.cdivision(True)
+2793: cdef inline void bubble_sort(unsigned char [::1] nums, int size)nogil:
static CYTHON_INLINE void __pyx_f_6shader_bubble_sort(__Pyx_memviewslice __pyx_v_nums, int __pyx_v_size) { int __pyx_v_i; unsigned char *__pyx_v_p; unsigned char *__pyx_v_p1; int __pyx_v_swapped; /* … */ /* function exit code */ }
2794: """
2795:
2796: :param nums:
2797: :param size:
2798: :return:
2799: """
2800: # We set swapped to True so the loop looks runs at least once
2801: cdef:
2802: int i, j
2803: unsigned char *p
2804: unsigned char *p1
2805: bint swapped
2806:
+2807: swapped = True
__pyx_v_swapped = 1;
+2808: while swapped:
while (1) { __pyx_t_1 = (__pyx_v_swapped != 0); if (!__pyx_t_1) break;
+2809: swapped = False
__pyx_v_swapped = 0;
+2810: for i in range(size - 1):
__pyx_t_2 = (__pyx_v_size - 1); __pyx_t_3 = __pyx_t_2; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4;
+2811: p = &nums[i]
__pyx_t_5 = __pyx_v_i; __pyx_v_p = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_5)) ))));
+2812: p1 = &nums[i+1]
__pyx_t_5 = (__pyx_v_i + 1); __pyx_v_p1 = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_5)) ))));
+2813: if p[0] > p1[0]:
__pyx_t_1 = (((__pyx_v_p[0]) > (__pyx_v_p1[0])) != 0); if (__pyx_t_1) { /* … */ } } }
+2814: p[0], p1[0] = p1[0], p[0]
__pyx_t_6 = (__pyx_v_p1[0]); __pyx_t_7 = (__pyx_v_p[0]); (__pyx_v_p[0]) = __pyx_t_6; (__pyx_v_p1[0]) = __pyx_t_7;
+2815: swapped = True
__pyx_v_swapped = 1;
2816:
2817:
2818: @cython.boundscheck(False)
2819: @cython.wraparound(False)
2820: @cython.nonecheck(False)
2821: @cython.cdivision(True)
+2822: cdef inline void insertion_sort(unsigned char [::1] nums, int size)nogil:
static CYTHON_INLINE void __pyx_f_6shader_insertion_sort(__Pyx_memviewslice __pyx_v_nums, CYTHON_UNUSED int __pyx_v_size) { int __pyx_v_i; int __pyx_v_j; unsigned char __pyx_v_item_to_insert; /* … */ /* function exit code */ }
2823: """
2824:
2825: :param nums:
2826: :param size:
2827: :return:
2828: """
2829:
2830: cdef:
2831: int i, j
2832: unsigned char item_to_insert
2833:
+2834: for i in prange(1, size, schedule='static', num_threads=THREADS):
__pyx_t_1 = __pyx_v_size; 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 - 1 + 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) lastprivate(__pyx_v_item_to_insert) lastprivate(__pyx_v_j) schedule(static) /* … */ __pyx_t_1 = __pyx_v_size; 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 - 1 + 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) lastprivate(__pyx_v_item_to_insert) lastprivate(__pyx_v_j) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){ { __pyx_v_i = (int)(1 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_item_to_insert = ((unsigned char)'?'); __pyx_v_j = ((int)0xbad0bad0);
+2835: item_to_insert = nums[i]
__pyx_t_4 = __pyx_v_i; __pyx_v_item_to_insert = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_4)) )));
2836:
+2837: j = i - 1
__pyx_v_j = (__pyx_v_i - 1);
+2838: while j >= 0 and nums[j] > item_to_insert:
while (1) { __pyx_t_6 = ((__pyx_v_j >= 0) != 0); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L9_bool_binop_done; } __pyx_t_4 = __pyx_v_j; __pyx_t_6 = (((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_4)) ))) > __pyx_v_item_to_insert) != 0); __pyx_t_5 = __pyx_t_6; __pyx_L9_bool_binop_done:; if (!__pyx_t_5) break;
+2839: nums[j + 1] = nums[j]
__pyx_t_4 = __pyx_v_j; __pyx_t_7 = (__pyx_v_j + 1); *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_7)) )) = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_4)) )));
+2840: j = j - 1
__pyx_v_j = (__pyx_v_j - 1); }
2841: # Insert the item
+2842: nums[j + 1] = item_to_insert
__pyx_t_4 = (__pyx_v_j + 1); *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_4)) )) = __pyx_v_item_to_insert; } } } } } #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
2843:
2844:
2845:
2846: @cython.boundscheck(False)
2847: @cython.wraparound(False)
2848: @cython.nonecheck(False)
2849: @cython.cdivision(True)
2850: # There are different ways to do a Quick Sort partition, this implements the
2851: # Hoare partition scheme. Tony Hoare also created the Quick Sort algorithm.
+2852: cdef inline int partition(unsigned char [::1] nums, int low, int high)nogil:
static CYTHON_INLINE int __pyx_f_6shader_partition(__Pyx_memviewslice __pyx_v_nums, int __pyx_v_low, int __pyx_v_high) { int __pyx_v_pivot; int __pyx_v_i; int __pyx_v_j; int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; __pyx_L0:; return __pyx_r; }
2853: """
2854:
2855: :param nums:
2856: :param low:
2857: :param high:
2858: :return:
2859: """
2860: cdef:
2861: int pivot
2862: int i, j
+2863: pivot = nums[(low + high) >> 1]
__pyx_t_1 = ((__pyx_v_low + __pyx_v_high) >> 1); __pyx_v_pivot = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) )));
+2864: i = low - 1
__pyx_v_i = (__pyx_v_low - 1);
+2865: j = high + 1
__pyx_v_j = (__pyx_v_high + 1);
+2866: while True:
while (1) {
+2867: i += 1
__pyx_v_i = (__pyx_v_i + 1);
+2868: while nums[i] < pivot:
while (1) { __pyx_t_1 = __pyx_v_i; __pyx_t_2 = (((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) ))) < __pyx_v_pivot) != 0); if (!__pyx_t_2) break;
+2869: i += 1
__pyx_v_i = (__pyx_v_i + 1); }
2870:
+2871: j -= 1
__pyx_v_j = (__pyx_v_j - 1);
+2872: while nums[j] > pivot:
while (1) { __pyx_t_1 = __pyx_v_j; __pyx_t_2 = (((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) ))) > __pyx_v_pivot) != 0); if (!__pyx_t_2) break;
+2873: j -= 1
__pyx_v_j = (__pyx_v_j - 1); }
2874:
+2875: if i >= j:
__pyx_t_2 = ((__pyx_v_i >= __pyx_v_j) != 0); if (__pyx_t_2) { /* … */ }
+2876: return j
__pyx_r = __pyx_v_j; goto __pyx_L0;
2877:
+2878: nums[i], nums[j] = nums[j], nums[i]
__pyx_t_1 = __pyx_v_j; __pyx_t_3 = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) ))); __pyx_t_1 = __pyx_v_i; __pyx_t_4 = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) ))); __pyx_t_1 = __pyx_v_i; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) )) = __pyx_t_3; __pyx_t_1 = __pyx_v_j; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_1)) )) = __pyx_t_4; }
2879:
2880:
2881: @cython.boundscheck(False)
2882: @cython.wraparound(False)
2883: @cython.nonecheck(False)
2884: @cython.cdivision(True)
+2885: cdef inline void _quick_sort(unsigned char [::1] items, int low, int high)nogil:
static CYTHON_INLINE void __pyx_f_6shader__quick_sort(__Pyx_memviewslice __pyx_v_items, int __pyx_v_low, int __pyx_v_high) { int __pyx_v_split_index; /* … */ /* function exit code */ }
2886: """
2887:
2888: :param items:
2889: :param low:
2890: :param high:
2891: :return:
2892: """
2893: cdef int split_index
+2894: if low < high:
__pyx_t_1 = ((__pyx_v_low < __pyx_v_high) != 0); if (__pyx_t_1) { /* … */ }
+2895: split_index = partition(items, low, high)
__pyx_v_split_index = __pyx_f_6shader_partition(__pyx_v_items, __pyx_v_low, __pyx_v_high);
+2896: _quick_sort(items, low, split_index)
__pyx_f_6shader__quick_sort(__pyx_v_items, __pyx_v_low, __pyx_v_split_index);
+2897: _quick_sort(items, split_index + 1, high)
__pyx_f_6shader__quick_sort(__pyx_v_items, (__pyx_v_split_index + 1), __pyx_v_high);
2898:
2899:
2900: @cython.boundscheck(False)
2901: @cython.wraparound(False)
2902: @cython.nonecheck(False)
2903: @cython.cdivision(True)
+2904: cdef inline void heapify(unsigned char [::1] nums, int heap_size, int root_index)nogil:
static CYTHON_INLINE void __pyx_f_6shader_heapify(__Pyx_memviewslice __pyx_v_nums, int __pyx_v_heap_size, int __pyx_v_root_index) { int __pyx_v_largest; int __pyx_v_left_child; int __pyx_v_right_child; /* … */ /* function exit code */ }
2905: """
2906:
2907: :param nums:
2908: :param heap_size:
2909: :param root_index:
2910: :return:
2911: """
2912: # Assume the index of the largest element is the root index
+2913: cdef int largest = root_index
__pyx_v_largest = __pyx_v_root_index;
+2914: cdef int left_child = (2 * root_index) + 1
__pyx_v_left_child = ((2 * __pyx_v_root_index) + 1);
+2915: cdef int right_child = (2 * root_index) + 2
__pyx_v_right_child = ((2 * __pyx_v_root_index) + 2);
2916:
+2917: if left_child < heap_size and nums[left_child] > nums[largest]:
__pyx_t_2 = ((__pyx_v_left_child < __pyx_v_heap_size) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = __pyx_v_left_child; __pyx_t_4 = __pyx_v_largest; __pyx_t_2 = (((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_3)) ))) > (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_4)) )))) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+2918: largest = left_child
__pyx_v_largest = __pyx_v_left_child;
2919:
+2920: if right_child < heap_size and nums[right_child] > nums[largest]:
__pyx_t_2 = ((__pyx_v_right_child < __pyx_v_heap_size) != 0); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L7_bool_binop_done; } __pyx_t_4 = __pyx_v_right_child; __pyx_t_3 = __pyx_v_largest; __pyx_t_2 = (((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_4)) ))) > (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_3)) )))) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L7_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+2921: largest = right_child
__pyx_v_largest = __pyx_v_right_child;
2922:
+2923: if largest != root_index:
__pyx_t_1 = ((__pyx_v_largest != __pyx_v_root_index) != 0); if (__pyx_t_1) { /* … */ }
+2924: nums[root_index], nums[largest] = nums[largest], nums[root_index]
__pyx_t_3 = __pyx_v_largest; __pyx_t_5 = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_3)) ))); __pyx_t_3 = __pyx_v_root_index; __pyx_t_6 = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_3)) ))); __pyx_t_3 = __pyx_v_root_index; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_3)) )) = __pyx_t_5; __pyx_t_3 = __pyx_v_largest; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_3)) )) = __pyx_t_6;
+2925: heapify(nums, heap_size, largest)
__pyx_f_6shader_heapify(__pyx_v_nums, __pyx_v_heap_size, __pyx_v_largest);
2926:
2927:
2928:
2929: @cython.boundscheck(False)
2930: @cython.wraparound(False)
2931: @cython.nonecheck(False)
2932: @cython.cdivision(True)
+2933: cdef inline void heap_sort(unsigned char [::1] nums, int n)nogil:
static CYTHON_INLINE void __pyx_f_6shader_heap_sort(__Pyx_memviewslice __pyx_v_nums, int __pyx_v_n) { long __pyx_v_i; /* … */ /* function exit code */ }
2934: """
2935:
2936: :param nums:
2937: :param n:
2938: :return:
2939: """
2940:
+2941: for i in range(n, -1, -1):
for (__pyx_t_1 = __pyx_v_n; __pyx_t_1 > -1L; __pyx_t_1-=1) { __pyx_v_i = __pyx_t_1;
+2942: heapify(nums, n, i)
__pyx_f_6shader_heapify(__pyx_v_nums, __pyx_v_n, __pyx_v_i); }
2943:
+2944: for i in range(n - 1, 0, -1):
for (__pyx_t_1 = (__pyx_v_n - 1); __pyx_t_1 > 0; __pyx_t_1-=1) { __pyx_v_i = __pyx_t_1;
+2945: nums[i], nums[0] = nums[0], nums[i]
__pyx_t_2 = 0; __pyx_t_3 = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_2)) ))); __pyx_t_2 = __pyx_v_i; __pyx_t_4 = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_2)) ))); __pyx_t_2 = __pyx_v_i; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_2)) )) = __pyx_t_3; __pyx_t_2 = 0; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_nums.data) + __pyx_t_2)) )) = __pyx_t_4;
+2946: heapify(nums, i, 0)
__pyx_f_6shader_heapify(__pyx_v_nums, __pyx_v_i, 0); }
2947:
2948:
2949:
2950: # *********** END OF SORTING ALGORITHM
2951:
2952:
2953: @cython.boundscheck(False)
2954: @cython.wraparound(False)
2955: @cython.nonecheck(False)
2956: @cython.cdivision(True)
+2957: cdef inline void shader_median_filter24_inplace_heapsort_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_median_filter24_inplace_heapsort_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_median_filter24_inplace_heapsort_c *__pyx_optional_args) { int __pyx_v_kernel_size_ = ((int)2); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_k; int __pyx_v_k_size; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_i; int __pyx_v_j; int __pyx_v_ky; int __pyx_v_kx; Py_ssize_t __pyx_v_ii; Py_ssize_t __pyx_v_jj; __Pyx_memviewslice __pyx_v_tmp_red = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_tmp_green = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_tmp_blue = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_index; CYTHON_UNUSED Py_ssize_t __pyx_v_w_1; Py_ssize_t __pyx_v_h_1; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_median_filter24_inplace_heapsort_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_WriteUnraisable("shader.shader_median_filter24_inplace_heapsort_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_red, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_green, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_blue, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_median_filter24_inplace_heapsort_c { int __pyx_n; int kernel_size_; };
2958: unsigned char [:, :, :] rgb_array_, int kernel_size_=2):
2959:
2960: """
2961: SHADER MEDIAN FILTER
2962:
2963: This shader cannot be used for real time rendering as the performance of the algorithm are not
2964: satisfactory. The code would have to be changed and improved with C or assembler in order to
2965: be adapted for a real time application. Another version can also be written with a surface
2966: downscale prior processing /rescale method that would boost the fps performance.
2967:
2968: In the state, this shader can be used for texture/surface transformation offline
2969:
2970: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
2971: please refer to pygame function pixels3d or array3d to convert an image into a 3d array
2972: (library surfarray)
2973:
2974: :param rgb_array_ : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
2975: pygame display pixels format RGB
2976: :param kernel_size_ : integer; size of the kernel
2977: :return : void
2978: """
2979:
2980: cdef Py_ssize_t w, h
+2981: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
2982:
2983: cdef:
+2984: int k = kernel_size_ >> 1
__pyx_v_k = (__pyx_v_kernel_size_ >> 1);
+2985: int k_size = kernel_size_ * kernel_size_
__pyx_v_k_size = (__pyx_v_kernel_size_ * __pyx_v_kernel_size_);
2986:
2987: cdef:
2988: unsigned char [:, :, ::1] rgb_array_copy = \
+2989: ascontiguousarray(numpy.array(rgb_array_, copy=True))
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_rgb_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(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 2989, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __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_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(1, 2989, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_copy = __pyx_t_10; __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL;
2990:
+2991: int i=0, j=0, ky, kx
__pyx_v_i = 0; __pyx_v_j = 0;
+2992: Py_ssize_t ii=0, jj=0
__pyx_v_ii = 0; __pyx_v_jj = 0;
2993:
+2994: unsigned char [::1] tmp_red = empty(k_size, numpy.uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_k_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_uint8); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 2994, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2994, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_tmp_red = __pyx_t_11; __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
+2995: unsigned char [::1] tmp_green = empty(k_size, numpy.uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_k_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); __pyx_t_6 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 2995, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2995, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_tmp_green = __pyx_t_11; __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
+2996: unsigned char [::1] tmp_blue = empty(k_size, numpy.uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_k_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 2996, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 2996, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_tmp_blue = __pyx_t_11; __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
2997:
+2998: int index = 0
__pyx_v_index = 0;
+2999: Py_ssize_t w_1 = w, h_1 = h
__pyx_v_w_1 = __pyx_v_w; __pyx_v_h_1 = __pyx_v_h;
3000:
+3001: 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:; } }
+3002: for i in prange(w_1, schedule='static', num_threads=THREADS, chunksize=2048):
__pyx_t_3 = __pyx_v_w_1; 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_3 - 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_ii) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) __pyx_t_13 = 0x800; /* … */ __pyx_t_3 = __pyx_v_w_1; 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_3 - 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_ii) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) schedule(static, __pyx_t_13) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_12; __pyx_t_2++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_ii = ((Py_ssize_t)0xbad0bad0); __pyx_v_index = ((int)0xbad0bad0); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_jj = ((Py_ssize_t)0xbad0bad0); __pyx_v_kx = ((int)0xbad0bad0); __pyx_v_ky = ((int)0xbad0bad0);
+3003: for j in range(h_1):
__pyx_t_14 = __pyx_v_h_1; __pyx_t_15 = __pyx_t_14; for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) { __pyx_v_j = __pyx_t_16;
3004:
+3005: index = 0
__pyx_v_index = 0;
3006:
+3007: for kx in range(-k, k):
__pyx_t_17 = __pyx_v_k; __pyx_t_18 = __pyx_t_17; for (__pyx_t_19 = (-__pyx_v_k); __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_kx = __pyx_t_19;
+3008: for ky in range(-k, k):
__pyx_t_20 = __pyx_v_k; __pyx_t_21 = __pyx_t_20; for (__pyx_t_22 = (-__pyx_v_k); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) { __pyx_v_ky = __pyx_t_22;
3009:
+3010: ii = i + kx
__pyx_v_ii = (__pyx_v_i + __pyx_v_kx);
+3011: jj = j + ky
__pyx_v_jj = (__pyx_v_j + __pyx_v_ky);
3012:
+3013: if ii < 0:
__pyx_t_23 = ((__pyx_v_ii < 0) != 0); if (__pyx_t_23) { /* … */ goto __pyx_L16; }
+3014: ii = 0
__pyx_v_ii = 0;
+3015: elif ii > w:
__pyx_t_23 = ((__pyx_v_ii > __pyx_v_w) != 0); if (__pyx_t_23) { /* … */ } __pyx_L16:;
+3016: ii = w
__pyx_v_ii = __pyx_v_w;
3017:
+3018: if jj < 0:
__pyx_t_23 = ((__pyx_v_jj < 0) != 0); if (__pyx_t_23) { /* … */ goto __pyx_L17; }
+3019: jj = 0
__pyx_v_jj = 0;
+3020: elif jj > h:
__pyx_t_23 = ((__pyx_v_jj > __pyx_v_h) != 0); if (__pyx_t_23) { /* … */ } __pyx_L17:;
+3021: jj = h
__pyx_v_jj = __pyx_v_h;
3022:
+3023: tmp_red[index] = rgb_array_copy[ii, jj, 0]
__pyx_t_24 = __pyx_v_ii; __pyx_t_25 = __pyx_v_jj; __pyx_t_26 = 0; __pyx_t_27 = __pyx_v_index; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_tmp_red.data) + __pyx_t_27)) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_24 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_25 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_26)) )));
+3024: tmp_green[index] = rgb_array_copy[ii, jj, 1]
__pyx_t_26 = __pyx_v_ii; __pyx_t_25 = __pyx_v_jj; __pyx_t_24 = 1; __pyx_t_27 = __pyx_v_index; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_tmp_green.data) + __pyx_t_27)) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_26 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_25 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_24)) )));
+3025: tmp_blue[index] = rgb_array_copy[ii, jj, 2]
__pyx_t_24 = __pyx_v_ii; __pyx_t_25 = __pyx_v_jj; __pyx_t_26 = 2; __pyx_t_27 = __pyx_v_index; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_tmp_blue.data) + __pyx_t_27)) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_24 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_25 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_26)) )));
+3026: index = index + 1
__pyx_v_index = (__pyx_v_index + 1); } }
3027:
+3028: heap_sort(tmp_red, k_size)
__pyx_f_6shader_heap_sort(__pyx_v_tmp_red, __pyx_v_k_size);
+3029: heap_sort(tmp_green, k_size)
__pyx_f_6shader_heap_sort(__pyx_v_tmp_green, __pyx_v_k_size);
+3030: heap_sort(tmp_blue, k_size)
__pyx_f_6shader_heap_sort(__pyx_v_tmp_blue, __pyx_v_k_size);
3031:
+3032: rgb_array_[i, j, 0] = tmp_red[k + 1]
__pyx_t_26 = (__pyx_v_k + 1); __pyx_t_25 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_27 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_27 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_tmp_red.data) + __pyx_t_26)) )));
+3033: rgb_array_[i, j, 1] = tmp_green[k + 1]
__pyx_t_26 = (__pyx_v_k + 1); __pyx_t_27 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_25 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_27 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_tmp_green.data) + __pyx_t_26)) )));
+3034: rgb_array_[i, j, 2]= tmp_blue[k + 1]
__pyx_t_26 = (__pyx_v_k + 1); __pyx_t_25 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_27 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_27 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_tmp_blue.data) + __pyx_t_26)) ))); } } } } } } #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 }
3035:
3036:
3037:
3038: @cython.boundscheck(False)
3039: @cython.wraparound(False)
3040: @cython.nonecheck(False)
3041: @cython.cdivision(True)
+3042: cdef inline void shader_median_filter24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_median_filter24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_median_filter24_inplace_c *__pyx_optional_args) { int __pyx_v_kernel_size_ = ((int)2); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_i; int __pyx_v_j; int __pyx_v_ky; int __pyx_v_kx; Py_ssize_t __pyx_v_ii; Py_ssize_t __pyx_v_jj; int __pyx_v_k; int __pyx_v_k_size; int *__pyx_v_tmp_red; int *__pyx_v_tmp_green; int *__pyx_v_tmp_blue; __Pyx_memviewslice __pyx_v_tmp_red_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_tmp_green_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_tmp_blue_ = { 0, 0, { 0 }, { 0 }, { 0 } }; int *__pyx_v_tmpr; int *__pyx_v_tmpg; int *__pyx_v_tmpb; int __pyx_v_index; CYTHON_UNUSED Py_ssize_t __pyx_v_w_1; CYTHON_UNUSED Py_ssize_t __pyx_v_h_1; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_median_filter24_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); __Pyx_XDECREF(((PyObject *)__pyx_t_11)); __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1); __Pyx_WriteUnraisable("shader.shader_median_filter24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_red_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_green_, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_tmp_blue_, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_median_filter24_inplace_c { int __pyx_n; int kernel_size_; };
3043: unsigned char [:, :, :] rgb_array_, int kernel_size_=2):
3044:
3045: """
3046: SHADER MEDIAN FILTER
3047:
3048: This shader cannot be used for real time rendering as the performance of the algorithm are not
3049: satisfactory. The code would have to be changed and improved with C or assembler in order to
3050: be adapted for a real time application. Another version can also be written with a surface
3051: downscale prior processing /rescale method that would boost the fps performance.
3052:
3053: In the state, this shader can be used for texture/surface transformation offline
3054:
3055: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3056: please refer to pygame function pixels3d or array3d to convert an image into a 3d array
3057: (library surfarray)
3058:
3059: :param rgb_array_ : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
3060: pygame display pixels format RGB
3061: :param kernel_size_ : integer; size of the kernel
3062: :return : void
3063: """
3064:
3065: cdef Py_ssize_t w, h
+3066: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3067:
3068: cdef:
3069: unsigned char [:, :, ::1] rgb_array_copy = \
+3070: ascontiguousarray(numpy.array(rgb_array_, copy=True))
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_rgb_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(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3070, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __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_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(1, 3070, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_copy = __pyx_t_10; __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL;
3071:
+3072: int i=0, j=0, ky, kx
__pyx_v_i = 0; __pyx_v_j = 0;
+3073: Py_ssize_t ii=0, jj=0
__pyx_v_ii = 0; __pyx_v_jj = 0;
+3074: int k = kernel_size_ >> 1
__pyx_v_k = (__pyx_v_kernel_size_ >> 1);
+3075: int k_size = kernel_size_ * kernel_size_
__pyx_v_k_size = (__pyx_v_kernel_size_ * __pyx_v_kernel_size_);
3076:
3077: # int [64] tmp_red = empty(64, numpy.int16, order='C')
3078: # int [64] tmp_green = empty(64, numpy.int16, order='C')
3079: # int [64] tmp_blue = empty(64, numpy.int16, order='C')
3080:
+3081: int *tmp_red = <int *> malloc(k_size * sizeof(int))
__pyx_v_tmp_red = ((int *)malloc((__pyx_v_k_size * (sizeof(int)))));
+3082: int *tmp_green = <int *> malloc(k_size * sizeof(int))
__pyx_v_tmp_green = ((int *)malloc((__pyx_v_k_size * (sizeof(int)))));
+3083: int *tmp_blue = <int *> malloc(k_size * sizeof(int))
__pyx_v_tmp_blue = ((int *)malloc((__pyx_v_k_size * (sizeof(int)))));
3084:
+3085: int [::1] tmp_red_ = <int[:k_size]>tmp_red
if (!__pyx_v_tmp_red) { PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer"); __PYX_ERR(1, 3085, __pyx_L1_error) } __pyx_t_5 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo_int); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = Py_BuildValue((char*) "(" __PYX_BUILD_PY_SSIZE_T ")", ((Py_ssize_t)__pyx_v_k_size)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = __pyx_array_new(__pyx_t_4, sizeof(int), PyBytes_AS_STRING(__pyx_t_5), (char *) "c", (char *) __pyx_v_tmp_red); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_t_11), PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(1, 3085, __pyx_L1_error) __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; __pyx_v_tmp_red_ = __pyx_t_12; __pyx_t_12.memview = NULL; __pyx_t_12.data = NULL;
+3086: int [::1] tmp_green_ = <int[:k_size]>tmp_green
if (!__pyx_v_tmp_green) { PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer"); __PYX_ERR(1, 3086, __pyx_L1_error) } __pyx_t_4 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo_int); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = Py_BuildValue((char*) "(" __PYX_BUILD_PY_SSIZE_T ")", ((Py_ssize_t)__pyx_v_k_size)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = __pyx_array_new(__pyx_t_5, sizeof(int), PyBytes_AS_STRING(__pyx_t_4), (char *) "c", (char *) __pyx_v_tmp_green); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_t_11), PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(1, 3086, __pyx_L1_error) __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; __pyx_v_tmp_green_ = __pyx_t_12; __pyx_t_12.memview = NULL; __pyx_t_12.data = NULL;
+3087: int [::1] tmp_blue_ = <int[:k_size]>tmp_blue
if (!__pyx_v_tmp_blue) { PyErr_SetString(PyExc_ValueError,"Cannot create cython.array from NULL pointer"); __PYX_ERR(1, 3087, __pyx_L1_error) } __pyx_t_5 = __pyx_format_from_typeinfo(&__Pyx_TypeInfo_int); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = Py_BuildValue((char*) "(" __PYX_BUILD_PY_SSIZE_T ")", ((Py_ssize_t)__pyx_v_k_size)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = __pyx_array_new(__pyx_t_4, sizeof(int), PyBytes_AS_STRING(__pyx_t_5), (char *) "c", (char *) __pyx_v_tmp_blue); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dc_int(((PyObject *)__pyx_t_11), PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(1, 3087, __pyx_L1_error) __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; __pyx_v_tmp_blue_ = __pyx_t_12; __pyx_t_12.memview = NULL; __pyx_t_12.data = NULL;
3088:
3089: int *tmpr
3090: int *tmpg
3091: int *tmpb
3092:
+3093: int index = 0
__pyx_v_index = 0;
+3094: Py_ssize_t w_1 = w, h_1 = h
__pyx_v_w_1 = __pyx_v_w; __pyx_v_h_1 = __pyx_v_h;
3095:
3096:
+3097: 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:; } }
+3098: for i in prange(w_1, schedule='static', num_threads=THREADS, chunksize=2048):
__pyx_t_3 = __pyx_v_w_1; 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_13 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_13 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_tmpb) lastprivate(__pyx_v_tmpg) lastprivate(__pyx_v_tmpr) __pyx_t_14 = 0x800; /* … */ __pyx_t_3 = __pyx_v_w_1; 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_13 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_13 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_tmpb) lastprivate(__pyx_v_tmpg) lastprivate(__pyx_v_tmpr) schedule(static, __pyx_t_14) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_13; __pyx_t_2++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_ii = ((Py_ssize_t)0xbad0bad0); __pyx_v_index = ((int)0xbad0bad0); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_jj = ((Py_ssize_t)0xbad0bad0); __pyx_v_kx = ((int)0xbad0bad0); __pyx_v_ky = ((int)0xbad0bad0); __pyx_v_tmpb = ((int *)1); __pyx_v_tmpg = ((int *)1); __pyx_v_tmpr = ((int *)1);
+3099: for j in prange(h_1):
__pyx_t_15 = __pyx_v_h_1; if ((1 == 0)) abort(); { __pyx_t_17 = (__pyx_t_15 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_17 > 0) { #if 0 #pragma omp parallel #endif /* _OPENMP */ { #if 0 #pragma omp for lastprivate(__pyx_v_ii) lastprivate(__pyx_v_index) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_tmpb) lastprivate(__pyx_v_tmpg) lastprivate(__pyx_v_tmpr) #endif /* _OPENMP */ for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_17; __pyx_t_16++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_16); /* Initialize private variables to invalid values */ __pyx_v_ii = ((Py_ssize_t)0xbad0bad0); __pyx_v_index = ((int)0xbad0bad0); __pyx_v_jj = ((Py_ssize_t)0xbad0bad0); __pyx_v_kx = ((int)0xbad0bad0); __pyx_v_ky = ((int)0xbad0bad0); __pyx_v_tmpb = ((int *)1); __pyx_v_tmpg = ((int *)1); __pyx_v_tmpr = ((int *)1);
3100:
+3101: index = 0
__pyx_v_index = 0;
3102:
+3103: for kx in range(-k, k):
__pyx_t_18 = __pyx_v_k; __pyx_t_19 = __pyx_t_18; for (__pyx_t_20 = (-__pyx_v_k); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_kx = __pyx_t_20;
+3104: for ky in range(-k, k):
__pyx_t_21 = __pyx_v_k; __pyx_t_22 = __pyx_t_21; for (__pyx_t_23 = (-__pyx_v_k); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_ky = __pyx_t_23;
3105:
+3106: ii = i + kx
__pyx_v_ii = (__pyx_v_i + __pyx_v_kx);
+3107: jj = j + ky
__pyx_v_jj = (__pyx_v_j + __pyx_v_ky);
3108:
+3109: if ii < 0:
__pyx_t_24 = ((__pyx_v_ii < 0) != 0); if (__pyx_t_24) { /* … */ goto __pyx_L18; }
+3110: ii = 0
__pyx_v_ii = 0;
+3111: elif ii > w:
__pyx_t_24 = ((__pyx_v_ii > __pyx_v_w) != 0); if (__pyx_t_24) { /* … */ } __pyx_L18:;
+3112: ii = w
__pyx_v_ii = __pyx_v_w;
3113:
+3114: if jj < 0:
__pyx_t_24 = ((__pyx_v_jj < 0) != 0); if (__pyx_t_24) { /* … */ goto __pyx_L19; }
+3115: jj = 0
__pyx_v_jj = 0;
+3116: elif jj > h:
__pyx_t_24 = ((__pyx_v_jj > __pyx_v_h) != 0); if (__pyx_t_24) { /* … */ } __pyx_L19:;
+3117: jj = h
__pyx_v_jj = __pyx_v_h;
3118:
+3119: tmp_red_[index] = rgb_array_copy[ii, jj, 0]
__pyx_t_25 = __pyx_v_ii; __pyx_t_26 = __pyx_v_jj; __pyx_t_27 = 0; __pyx_t_28 = __pyx_v_index; *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_tmp_red_.data) + __pyx_t_28)) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_25 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_26 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_27)) )));
+3120: tmp_green_[index] = rgb_array_copy[ii, jj, 1]
__pyx_t_27 = __pyx_v_ii; __pyx_t_26 = __pyx_v_jj; __pyx_t_25 = 1; __pyx_t_28 = __pyx_v_index; *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_tmp_green_.data) + __pyx_t_28)) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_27 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_26 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_25)) )));
+3121: tmp_blue_[index] = rgb_array_copy[ii, jj, 2]
__pyx_t_25 = __pyx_v_ii; __pyx_t_26 = __pyx_v_jj; __pyx_t_27 = 2; __pyx_t_28 = __pyx_v_index; *((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_tmp_blue_.data) + __pyx_t_28)) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_25 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_26 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_27)) )));
+3122: index = index + 1
__pyx_v_index = (__pyx_v_index + 1); } }
3123:
3124: # External C quicksort
+3125: tmpr = quickSort(&tmp_red_[0], 0, k_size)
__pyx_t_27 = 0; __pyx_v_tmpr = quickSort((&(*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_tmp_red_.data) + __pyx_t_27)) )))), 0, __pyx_v_k_size);
+3126: tmpg = quickSort(&tmp_green[0], 0, k_size)
__pyx_v_tmpg = quickSort((&(__pyx_v_tmp_green[0])), 0, __pyx_v_k_size);
+3127: tmpb = quickSort(&tmp_blue[0], 0, k_size)
__pyx_v_tmpb = quickSort((&(__pyx_v_tmp_blue[0])), 0, __pyx_v_k_size);
3128:
+3129: rgb_array_[i, j, 0] = tmpr[k + 1]
__pyx_t_27 = __pyx_v_i; __pyx_t_26 = __pyx_v_j; __pyx_t_25 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_27 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_26 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_tmpr[(__pyx_v_k + 1)]);
+3130: rgb_array_[i, j, 1] = tmpg[k + 1]
__pyx_t_25 = __pyx_v_i; __pyx_t_26 = __pyx_v_j; __pyx_t_27 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_26 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_27 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_tmpg[(__pyx_v_k + 1)]);
+3131: rgb_array_[i, j, 2] = tmpb[k + 1]
__pyx_t_27 = __pyx_v_i; __pyx_t_26 = __pyx_v_j; __pyx_t_25 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_27 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_26 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_tmpb[(__pyx_v_k + 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 }
3132:
3133:
3134:
3135: @cython.boundscheck(False)
3136: @cython.wraparound(False)
3137: @cython.nonecheck(False)
3138: @cython.cdivision(True)
+3139: cdef inline void shader_median_filter24_avg_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_median_filter24_avg_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_median_filter24_avg_inplace_c *__pyx_optional_args) { int __pyx_v_kernel_size_ = ((int)2); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; CYTHON_UNUSED __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_i; int __pyx_v_j; int __pyx_v_ky; int __pyx_v_kx; Py_ssize_t __pyx_v_ii; Py_ssize_t __pyx_v_jj; int __pyx_v_k; CYTHON_UNUSED int __pyx_v_k_size; Py_ssize_t __pyx_v_w_1; Py_ssize_t __pyx_v_h_1; unsigned char __pyx_v_max_r; unsigned char __pyx_v_min_r; unsigned char __pyx_v_max_g; unsigned char __pyx_v_min_g; unsigned char __pyx_v_max_b; unsigned char __pyx_v_min_b; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_median_filter24_avg_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); __Pyx_WriteUnraisable("shader.shader_median_filter24_avg_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_median_filter24_avg_inplace_c { int __pyx_n; int kernel_size_; };
3140: unsigned char [:, :, :] rgb_array_, int kernel_size_=2):
3141:
3142: """
3143: SHADER MEDIAN FILTER
3144:
3145: This shader cannot be used for real time rendering as the performance of the algorithm are not
3146: satisfactory. The code would have to be changed and improved with C or assembler in order to
3147: be adapted for a real time application. Another version can also be written with a surface
3148: downscale prior processing /rescale method that would boost the fps performance.
3149:
3150: In the state, this shader can be used for texture/surface transformation offline
3151:
3152: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3153: please refer to pygame function pixels3d or array3d to convert an image into a
3154: 3d array (library surfarray)
3155:
3156: :param rgb_array_ : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
3157: pygame display pixels format RGB
3158: :param kernel_size_ : integer; size of the kernel
3159: :return : void
3160: """
3161:
3162: cdef Py_ssize_t w, h
+3163: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3164:
3165: cdef:
3166: unsigned char [:, :, ::1] rgb_array_copy = \
+3167: ascontiguousarray(numpy.array(rgb_array_, copy=True))
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_rgb_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(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3167, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __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_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(1, 3167, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_copy = __pyx_t_10; __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL;
3168:
+3169: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
3170: int ky, kx
+3171: Py_ssize_t ii=0, jj=0
__pyx_v_ii = 0; __pyx_v_jj = 0;
+3172: int k = kernel_size_ >> 1
__pyx_v_k = (__pyx_v_kernel_size_ >> 1);
+3173: int k_size = kernel_size_ * kernel_size_
__pyx_v_k_size = (__pyx_v_kernel_size_ * __pyx_v_kernel_size_);
3174:
+3175: Py_ssize_t w_1 = w - 1, h_1 = h - 1
__pyx_v_w_1 = (__pyx_v_w - 1); __pyx_v_h_1 = (__pyx_v_h - 1);
3176: int red, green, blue
3177: unsigned char max_r, min_r, max_g, min_g, max_b, min_b
3178: unsigned char *r
3179: unsigned char *g
3180: unsigned char *b
3181:
+3182: 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:; } }
+3183: for i in prange(w, schedule='static', num_threads=THREADS, chunksize=2048):
__pyx_t_3 = __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_11 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_max_b) lastprivate(__pyx_v_max_g) lastprivate(__pyx_v_max_r) lastprivate(__pyx_v_min_b) lastprivate(__pyx_v_min_g) lastprivate(__pyx_v_min_r) lastprivate(__pyx_v_r) __pyx_t_12 = 0x800; /* … */ __pyx_t_3 = __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_11 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_max_b) lastprivate(__pyx_v_max_g) lastprivate(__pyx_v_max_r) lastprivate(__pyx_v_min_b) lastprivate(__pyx_v_min_g) lastprivate(__pyx_v_min_r) lastprivate(__pyx_v_r) schedule(static, __pyx_t_12) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_11; __pyx_t_2++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_ii = ((Py_ssize_t)0xbad0bad0); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_jj = ((Py_ssize_t)0xbad0bad0); __pyx_v_kx = ((int)0xbad0bad0); __pyx_v_ky = ((int)0xbad0bad0); __pyx_v_max_b = ((unsigned char)'?'); __pyx_v_max_g = ((unsigned char)'?'); __pyx_v_max_r = ((unsigned char)'?'); __pyx_v_min_b = ((unsigned char)'?'); __pyx_v_min_g = ((unsigned char)'?'); __pyx_v_min_r = ((unsigned char)'?'); __pyx_v_r = ((unsigned char *)1);
+3184: for j in range(h):
__pyx_t_13 = __pyx_v_h; __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;
3185:
+3186: max_r = 0
__pyx_v_max_r = 0;
+3187: min_r = 0
__pyx_v_min_r = 0;
+3188: max_g = 0
__pyx_v_max_g = 0;
+3189: min_g = 0
__pyx_v_min_g = 0;
+3190: max_b = 0
__pyx_v_max_b = 0;
+3191: min_b = 0
__pyx_v_min_b = 0;
3192:
+3193: for kx in range(-k, k):
__pyx_t_16 = __pyx_v_k; __pyx_t_17 = __pyx_t_16; for (__pyx_t_18 = (-__pyx_v_k); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_kx = __pyx_t_18;
+3194: for ky in range(-k, k):
__pyx_t_19 = __pyx_v_k; __pyx_t_20 = __pyx_t_19; for (__pyx_t_21 = (-__pyx_v_k); __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) { __pyx_v_ky = __pyx_t_21;
+3195: ii = (i + kx)
__pyx_v_ii = (__pyx_v_i + __pyx_v_kx);
+3196: jj = (j + ky)
__pyx_v_jj = (__pyx_v_j + __pyx_v_ky);
3197:
+3198: if ii < 0:
__pyx_t_22 = ((__pyx_v_ii < 0) != 0); if (__pyx_t_22) { /* … */ goto __pyx_L16; }
+3199: ii = 0
__pyx_v_ii = 0;
+3200: elif ii > w_1:
__pyx_t_22 = ((__pyx_v_ii > __pyx_v_w_1) != 0); if (__pyx_t_22) { /* … */ } __pyx_L16:;
+3201: ii = w_1
__pyx_v_ii = __pyx_v_w_1;
3202:
+3203: if jj < 0:
__pyx_t_22 = ((__pyx_v_jj < 0) != 0); if (__pyx_t_22) { /* … */ goto __pyx_L17; }
+3204: jj = 0
__pyx_v_jj = 0;
+3205: elif jj > h_1:
__pyx_t_22 = ((__pyx_v_jj > __pyx_v_h_1) != 0); if (__pyx_t_22) { /* … */ } __pyx_L17:;
+3206: jj = h_1
__pyx_v_jj = __pyx_v_h_1;
3207:
+3208: r = &rgb_array_[ii, jj, 0]
__pyx_t_23 = __pyx_v_ii; __pyx_t_24 = __pyx_v_jj; __pyx_t_25 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_23 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) ))));
+3209: g = &rgb_array_[ii, jj, 1]
__pyx_t_25 = __pyx_v_ii; __pyx_t_24 = __pyx_v_jj; __pyx_t_23 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[2]) ))));
+3210: b = &rgb_array_[ii, jj, 2]
__pyx_t_23 = __pyx_v_ii; __pyx_t_24 = __pyx_v_jj; __pyx_t_25 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_23 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) ))));
3211:
+3212: if r[0] > max_r:
__pyx_t_22 = (((__pyx_v_r[0]) > __pyx_v_max_r) != 0); if (__pyx_t_22) { /* … */ }
+3213: max_r = r[0]
__pyx_v_max_r = (__pyx_v_r[0]);
+3214: if g[0] > max_g:
__pyx_t_22 = (((__pyx_v_g[0]) > __pyx_v_max_g) != 0); if (__pyx_t_22) { /* … */ }
+3215: max_g = g[0]
__pyx_v_max_g = (__pyx_v_g[0]);
+3216: if b[0] > max_b:
__pyx_t_22 = (((__pyx_v_b[0]) > __pyx_v_max_b) != 0); if (__pyx_t_22) { /* … */ }
+3217: max_b = b[0]
__pyx_v_max_b = (__pyx_v_b[0]);
3218:
+3219: if r[0] < min_r:
__pyx_t_22 = (((__pyx_v_r[0]) < __pyx_v_min_r) != 0); if (__pyx_t_22) { /* … */ }
+3220: min_r = r[0]
__pyx_v_min_r = (__pyx_v_r[0]);
+3221: if g[0] < min_g:
__pyx_t_22 = (((__pyx_v_g[0]) < __pyx_v_min_g) != 0); if (__pyx_t_22) { /* … */ }
+3222: min_g = g[0]
__pyx_v_min_g = (__pyx_v_g[0]);
+3223: if b[0] < min_b:
__pyx_t_22 = (((__pyx_v_b[0]) < __pyx_v_min_b) != 0); if (__pyx_t_22) { /* … */ } } }
+3224: min_b = b[0]
__pyx_v_min_b = (__pyx_v_b[0]);
3225:
+3226: rgb_array_[i, j, 0] = <unsigned char>((max_r - min_r) *0.5)
__pyx_t_25 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_23 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((__pyx_v_max_r - __pyx_v_min_r) * 0.5));
+3227: rgb_array_[i, j, 1] = <unsigned char>((max_g - min_g) *0.5)
__pyx_t_23 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_25 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_23 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((__pyx_v_max_g - __pyx_v_min_g) * 0.5));
+3228: rgb_array_[i, j, 2] = <unsigned char>((max_b - min_b) *0.5)
__pyx_t_25 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_23 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((__pyx_v_max_b - __pyx_v_min_b) * 0.5)); } } } } } } #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 }
3229:
3230:
3231:
3232: @cython.boundscheck(False)
3233: @cython.wraparound(False)
3234: @cython.nonecheck(False)
3235: @cython.cdivision(True)
+3236: cdef inline void shader_median_grayscale_filter24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_median_grayscale_filter24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_median_grayscale_filter24_inplace_c *__pyx_optional_args) { int __pyx_v_kernel_size_ = ((int)2); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_i; int __pyx_v_j; int __pyx_v_ky; int __pyx_v_kx; Py_ssize_t __pyx_v_ii; Py_ssize_t __pyx_v_jj; int __pyx_v_k; int __pyx_v_k_size; int *__pyx_v_tmp_; int *__pyx_v_tmp; int __pyx_v_index; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_median_grayscale_filter24_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_kernel_size_ = __pyx_optional_args->kernel_size_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1); __Pyx_WriteUnraisable("shader.shader_median_grayscale_filter24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_median_grayscale_filter24_inplace_c { int __pyx_n; int kernel_size_; };
3237: unsigned char [:, :, :] rgb_array_, int kernel_size_=2):
3238:
3239: """
3240: SHADER MEDIAN FILTER
3241:
3242: This shader cannot be used for real time rendering as the performance of the algorithm are not
3243: satisfactory. The code would have to be changed and improved with C or assembler in order to
3244: be adapted for a real time application. Another version can also be written with a surface
3245: downscale prior processing /rescale method that would boost the fps performance.
3246:
3247: In the state, this shader can be used for texture/surface transformation offline
3248:
3249: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3250: please refer to pygame function pixels3d or array3d to convert an image into a 3d
3251: array (library surfarray)
3252:
3253: :param rgb_array_ : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
3254: pygame display pixels format RGB
3255: :param kernel_size_ : integer; size of the kernel
3256: :return : void
3257: """
3258:
3259: cdef Py_ssize_t w, h
+3260: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3261:
3262: cdef:
3263: unsigned char [:, :, ::1] rgb_array_copy = \
+3264: ascontiguousarray(numpy.array(rgb_array_, copy=True))
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_rgb_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(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3264, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __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_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(1, 3264, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_copy = __pyx_t_10; __pyx_t_10.memview = NULL; __pyx_t_10.data = NULL;
3265:
+3266: int i=0, j=0, ky, kx
__pyx_v_i = 0; __pyx_v_j = 0;
+3267: Py_ssize_t ii=0, jj=0
__pyx_v_ii = 0; __pyx_v_jj = 0;
3268:
+3269: int k = kernel_size_ >> 1
__pyx_v_k = (__pyx_v_kernel_size_ >> 1);
+3270: int k_size = kernel_size_ * kernel_size_
__pyx_v_k_size = (__pyx_v_kernel_size_ * __pyx_v_kernel_size_);
3271: # int [64] tmp_ = empty(64, numpy.int16, order='C')
+3272: int *tmp_ = <int *> malloc(k_size * sizeof(int))
__pyx_v_tmp_ = ((int *)malloc((__pyx_v_k_size * (sizeof(int)))));
3273: int *tmp
+3274: int index = 0
__pyx_v_index = 0;
3275: unsigned char *v
3276:
3277:
+3278: 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:; } }
+3279: for i in prange(0, w, schedule='static', num_threads=THREADS, chunksize=2048):
__pyx_t_3 = __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_11 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_tmp) __pyx_t_12 = 0x800; /* … */ __pyx_t_3 = __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_11 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_index) lastprivate(__pyx_v_j) lastprivate(__pyx_v_jj) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_tmp) schedule(static, __pyx_t_12) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_11; __pyx_t_2++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_ii = ((Py_ssize_t)0xbad0bad0); __pyx_v_index = ((int)0xbad0bad0); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_jj = ((Py_ssize_t)0xbad0bad0); __pyx_v_kx = ((int)0xbad0bad0); __pyx_v_ky = ((int)0xbad0bad0); __pyx_v_tmp = ((int *)1);
+3280: for j in range(0, h):
__pyx_t_13 = __pyx_v_h; __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;
3281:
+3282: index = 0
__pyx_v_index = 0;
3283:
+3284: for kx in range(-k, k):
__pyx_t_16 = __pyx_v_k; __pyx_t_17 = __pyx_t_16; for (__pyx_t_18 = (-__pyx_v_k); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_kx = __pyx_t_18;
+3285: for ky in range(-k, k):
__pyx_t_19 = __pyx_v_k; __pyx_t_20 = __pyx_t_19; for (__pyx_t_21 = (-__pyx_v_k); __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) { __pyx_v_ky = __pyx_t_21;
3286:
+3287: ii = i + kx
__pyx_v_ii = (__pyx_v_i + __pyx_v_kx);
+3288: jj = j + ky
__pyx_v_jj = (__pyx_v_j + __pyx_v_ky);
3289:
+3290: if ii < 0:
__pyx_t_22 = ((__pyx_v_ii < 0) != 0); if (__pyx_t_22) { /* … */ goto __pyx_L16; }
+3291: ii = 0
__pyx_v_ii = 0;
+3292: elif ii > w:
__pyx_t_22 = ((__pyx_v_ii > __pyx_v_w) != 0); if (__pyx_t_22) { /* … */ } __pyx_L16:;
+3293: ii = w
__pyx_v_ii = __pyx_v_w;
3294:
+3295: if jj < 0:
__pyx_t_22 = ((__pyx_v_jj < 0) != 0); if (__pyx_t_22) { /* … */ goto __pyx_L17; }
+3296: jj = 0
__pyx_v_jj = 0;
+3297: elif jj > h:
__pyx_t_22 = ((__pyx_v_jj > __pyx_v_h) != 0); if (__pyx_t_22) { /* … */ } __pyx_L17:;
+3298: jj = h
__pyx_v_jj = __pyx_v_h;
3299:
+3300: tmp_[index] = rgb_array_copy[ii, jj, 0]
__pyx_t_23 = __pyx_v_ii; __pyx_t_24 = __pyx_v_jj; __pyx_t_25 = 0; (__pyx_v_tmp_[__pyx_v_index]) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_23 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_25)) )));
3301:
+3302: index = index + 1
__pyx_v_index = (__pyx_v_index + 1); } }
3303:
+3304: tmp = quickSort(tmp_, 0, k_size)
__pyx_v_tmp = quickSort(__pyx_v_tmp_, 0, __pyx_v_k_size);
3305:
+3306: rgb_array_[i, j, 0] = tmp[k + 1]
__pyx_t_25 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_23 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_tmp[(__pyx_v_k + 1)]);
+3307: rgb_array_[i, j, 1] = tmp[k + 1]
__pyx_t_23 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_25 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_23 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_tmp[(__pyx_v_k + 1)]);
+3308: rgb_array_[i, j, 2] = tmp[k + 1]
__pyx_t_25 = __pyx_v_i; __pyx_t_24 = __pyx_v_j; __pyx_t_23 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_tmp[(__pyx_v_k + 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 }
3309:
3310:
3311:
+3312: cdef float ONE_255 = <float>1.0 / <float>255.0
__pyx_v_6shader_ONE_255 = (((float)1.0) / ((float)255.0));
3313:
3314: @cython.boundscheck(False)
3315: @cython.wraparound(False)
3316: @cython.nonecheck(False)
3317: @cython.cdivision(True)
+3318: cdef inline void shader_color_reduction24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_color_reduction24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array, int __pyx_v_color_number) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; float __pyx_v_f; float __pyx_v_c1; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_color_reduction24_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
3319: unsigned char [:, :, :] rgb_array, int color_number):
3320: """
3321: COLOR REDUCTION SHADER
3322:
3323: Decrease the amount of colors in the display or texture.
3324: The method of color reduction is very simple: every color of the original picture is replaced
3325: by an appropriate color from the limited palette that is accessible.
3326:
3327: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3328: please refer to pygame function pixels3d or array3d to convert an image into a 3d array
3329: (library surfarray)
3330:
3331: e.g:
3332: color_reduction(surface, 8)
3333:
3334: :param rgb_array : numpy.ndarray shape(w, h, 3) uint8 (unsigned char 0...255) containing the
3335: pygame display pixels format RGB
3336: :param color_number : integer; color number color_number^2
3337: :return : void
3338: """
3339:
3340:
3341: cdef Py_ssize_t w, h
+3342: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3343:
3344: # cdef float color_number = <float>pow(2, factor)
3345:
3346: cdef:
+3347: int x=0, y=0
__pyx_v_x = 0; __pyx_v_y = 0;
3348: unsigned char *r
3349: unsigned char *g
3350: unsigned char *b
+3351: float f = <float> 255.0 / <float> color_number
__pyx_v_f = (((float)255.0) / ((float)__pyx_v_color_number));
+3352: float c1 = <float>color_number / <float>255.0
__pyx_v_c1 = (((float)__pyx_v_color_number) / ((float)255.0));
3353:
+3354: 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:; } }
+3355: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_r) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_r) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_r = ((unsigned char *)1); __pyx_v_x = ((int)0xbad0bad0);
+3356: for x in range(0, w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_x = __pyx_t_7;
3357:
+3358: r = &rgb_array[x, y, 0]
__pyx_t_8 = __pyx_v_x; __pyx_t_9 = __pyx_v_y; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+3359: g = &rgb_array[x, y, 1]
__pyx_t_10 = __pyx_v_x; __pyx_t_9 = __pyx_v_y; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+3360: b = &rgb_array[x, y, 2]
__pyx_t_8 = __pyx_v_x; __pyx_t_9 = __pyx_v_y; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
3361:
+3362: r[0] = <unsigned char>(<int>(<float>round_c(c1 * <float>r[0]) * f))
(__pyx_v_r[0]) = ((unsigned char)((int)(((float)round((__pyx_v_c1 * ((float)(__pyx_v_r[0]))))) * __pyx_v_f)));
+3363: g[0] = <unsigned char>(<int>(<float>round_c(c1 * <float>g[0]) * f))
(__pyx_v_g[0]) = ((unsigned char)((int)(((float)round((__pyx_v_c1 * ((float)(__pyx_v_g[0]))))) * __pyx_v_f)));
+3364: b[0] = <unsigned char>(<int>(<float>round_c(c1 * <float>b[0]) * f))
(__pyx_v_b[0]) = ((unsigned char)((int)(((float)round((__pyx_v_c1 * ((float)(__pyx_v_b[0]))))) * __pyx_v_f))); } } } } } } #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 }
3365:
3366:
3367:
3368: cdef:
+3369: short [:, ::1] GY = numpy.array(
__Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_numpy); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 3369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_n_s_array_2); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 3369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; /* … */ __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_30, __pyx_t_31); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
+3370: ([-1, 0, 1],
__pyx_t_33 = PyList_New(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 3370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_33, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_33, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_33, 2, __pyx_int_1); /* … */ __pyx_t_31 = PyTuple_New(3); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 3370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_31, 0, __pyx_t_33); __Pyx_GIVEREF(__pyx_t_32); PyTuple_SET_ITEM(__pyx_t_31, 1, __pyx_t_32); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_31, 2, __pyx_t_2); __pyx_t_33 = 0; __pyx_t_32 = 0; __pyx_t_2 = 0;
+3371: [-2, 0, 2],
__pyx_t_32 = PyList_New(3); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 3371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_INCREF(__pyx_int_neg_2); __Pyx_GIVEREF(__pyx_int_neg_2); PyList_SET_ITEM(__pyx_t_32, 0, __pyx_int_neg_2); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_32, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); PyList_SET_ITEM(__pyx_t_32, 2, __pyx_int_2);
+3372: [-1, 0, 1])).astype(dtype=int16, order='C')
__pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_1); /* … */ __pyx_t_31 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_astype); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_n_s_int16); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_30) < 0) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 3372, __pyx_L1_error) __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_31, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_35 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_30, PyBUF_WRITABLE); if (unlikely(!__pyx_t_35.memview)) __PYX_ERR(1, 3372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_GY, 1); __pyx_v_6shader_GY = __pyx_t_35; __pyx_t_35.memview = NULL; __pyx_t_35.data = NULL;
3373:
+3374: short [:, ::1] GX = numpy.array(
__Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_n_s_numpy); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 3374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_n_s_array_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; /* … */ __pyx_t_32 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_33); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 3374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
+3375: ([-1, -2, -1],
__pyx_t_30 = PyList_New(3); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 3375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_30, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_2); __Pyx_GIVEREF(__pyx_int_neg_2); PyList_SET_ITEM(__pyx_t_30, 1, __pyx_int_neg_2); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_30, 2, __pyx_int_neg_1); /* … */ __pyx_t_33 = PyTuple_New(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 3375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_GIVEREF(__pyx_t_30); PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_t_30); __Pyx_GIVEREF(__pyx_t_31); PyTuple_SET_ITEM(__pyx_t_33, 1, __pyx_t_31); __Pyx_GIVEREF(__pyx_t_32); PyTuple_SET_ITEM(__pyx_t_33, 2, __pyx_t_32); __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
+3376: [0, 0, 0],
__pyx_t_31 = PyList_New(3); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 3376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_31, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_31, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_31, 2, __pyx_int_0);
+3377: [1, 2, 1])).astype(dtype=int16, order='c')
__pyx_t_32 = PyList_New(3); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_32, 0, __pyx_int_1); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); PyList_SET_ITEM(__pyx_t_32, 1, __pyx_int_2); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_32, 2, __pyx_int_1); /* … */ __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_32, __pyx_n_s_astype); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __pyx_t_32 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_int16); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_32, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_32, __pyx_n_s_order, __pyx_n_s_c_2) < 0) __PYX_ERR(1, 3377, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_33, __pyx_empty_tuple, __pyx_t_32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __pyx_t_35 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_short(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_35.memview)) __PYX_ERR(1, 3377, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_GX, 1); __pyx_v_6shader_GX = __pyx_t_35; __pyx_t_35.memview = NULL; __pyx_t_35.data = NULL;
3378:
+3379: unsigned short int KERNEL_HALF = 1
__pyx_v_6shader_KERNEL_HALF = 1;
3380:
3381:
3382: @cython.boundscheck(False)
3383: @cython.wraparound(False)
3384: @cython.nonecheck(False)
3385: @cython.cdivision(True)
+3386: cdef inline void shader_sobel24_inplace_c(unsigned char [:, :, :] rgb_array, float threshold=20.0):
static CYTHON_INLINE void __pyx_f_6shader_shader_sobel24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array, struct __pyx_opt_args_6shader_shader_sobel24_inplace_c *__pyx_optional_args) { float __pyx_v_threshold = ((float)20.0); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; Py_ssize_t __pyx_v_w_1; Py_ssize_t __pyx_v_h_1; int __pyx_v_kernel_offset_x; int __pyx_v_kernel_offset_y; __Pyx_memviewslice __pyx_v_source_array = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; Py_ssize_t __pyx_v_xx; Py_ssize_t __pyx_v_yy; float __pyx_v_r_gx; float __pyx_v_r_gy; unsigned char *__pyx_v_gray; unsigned char __pyx_v_m; float __pyx_v_magnitude; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_sobel24_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold = __pyx_optional_args->threshold; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_sobel24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_source_array, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_sobel24_inplace_c { int __pyx_n; float threshold; };
3387: """
3388: SHADER SOBEL (EDGE DETECTION)
3389:
3390: Transform the game display or a pygame surface into a sobel equivalent model
3391: (surface edge detection)
3392:
3393: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3394: please refer to pygame function pixels3d or array3d to convert an image into a 3d
3395: array (library surfarray)
3396:
3397: e.g:
3398: sobel(surface, 64)
3399:
3400: :param rgb_array : numpy.ndarray shape (w, h, 3) containing RGB values
3401: :param threshold : float; Threshold value (Default value = 20.0)
3402: :return : void
3403: """
3404:
3405: cdef Py_ssize_t w, h
+3406: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3407:
3408: cdef:
+3409: Py_ssize_t w_1 = w - 1
__pyx_v_w_1 = (__pyx_v_w - 1);
+3410: Py_ssize_t h_1 = h - 1
__pyx_v_h_1 = (__pyx_v_h - 1);
3411: int kernel_offset_x, kernel_offset_y
+3412: unsigned char [:, :, :] source_array = numpy.array(rgb_array, copy=True)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3412, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3412, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_source_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
3413: int x, y
3414: Py_ssize_t xx, yy
3415: float r_gx, r_gy
3416: unsigned char *gray
3417: unsigned char m
3418: float magnitude
3419:
+3420: 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_L4_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L5:; } }
3421:
+3422: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_gray) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_m) lastprivate(__pyx_v_magnitude) lastprivate(__pyx_v_r_gx) lastprivate(__pyx_v_r_gy) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_gray) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_m) lastprivate(__pyx_v_magnitude) lastprivate(__pyx_v_r_gx) lastprivate(__pyx_v_r_gy) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_9; __pyx_t_2++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_gray = ((unsigned char *)1); __pyx_v_kernel_offset_x = ((int)0xbad0bad0); __pyx_v_kernel_offset_y = ((int)0xbad0bad0); __pyx_v_m = ((unsigned char)'?'); __pyx_v_magnitude = ((float)__PYX_NAN()); __pyx_v_r_gx = ((float)__PYX_NAN()); __pyx_v_r_gy = ((float)__PYX_NAN()); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_xx = ((Py_ssize_t)0xbad0bad0); __pyx_v_yy = ((Py_ssize_t)0xbad0bad0);
3423:
+3424: for x in range(w):
__pyx_t_10 = __pyx_v_w; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_x = __pyx_t_12;
3425:
+3426: r_gx, r_gy = <float>0.0, <float>0.0
__pyx_t_13 = ((float)0.0); __pyx_t_14 = ((float)0.0); __pyx_v_r_gx = __pyx_t_13; __pyx_v_r_gy = __pyx_t_14;
3427:
+3428: for kernel_offset_x in range(-KERNEL_HALF, KERNEL_HALF + 1):
__pyx_t_15 = (__pyx_v_6shader_KERNEL_HALF + 1); __pyx_t_16 = __pyx_t_15; for (__pyx_t_17 = (-__pyx_v_6shader_KERNEL_HALF); __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_kernel_offset_x = __pyx_t_17;
3429:
+3430: for kernel_offset_y in range(-KERNEL_HALF, KERNEL_HALF + 1):
__pyx_t_18 = (__pyx_v_6shader_KERNEL_HALF + 1); __pyx_t_19 = __pyx_t_18; for (__pyx_t_20 = (-__pyx_v_6shader_KERNEL_HALF); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_kernel_offset_y = __pyx_t_20;
3431:
+3432: xx = x + kernel_offset_x
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset_x);
+3433: yy = y + kernel_offset_y
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset_y);
3434:
+3435: if xx > w_1:
__pyx_t_21 = ((__pyx_v_xx > __pyx_v_w_1) != 0); if (__pyx_t_21) { /* … */ }
+3436: xx = w_1
__pyx_v_xx = __pyx_v_w_1;
+3437: if xx < 0:
__pyx_t_21 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_21) { /* … */ }
+3438: xx = 0
__pyx_v_xx = 0;
3439:
+3440: if yy > h_1:
__pyx_t_21 = ((__pyx_v_yy > __pyx_v_h_1) != 0); if (__pyx_t_21) { /* … */ }
+3441: yy = h_1
__pyx_v_yy = __pyx_v_h_1;
+3442: if yy < 0:
__pyx_t_21 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_21) { /* … */ }
+3443: yy = 0
__pyx_v_yy = 0;
3444:
3445: # grayscale image red = green = blue
+3446: gray = &source_array[xx, yy, 0]
__pyx_t_22 = __pyx_v_xx; __pyx_t_23 = __pyx_v_yy; __pyx_t_24 = 0; __pyx_v_gray = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_22 * __pyx_v_source_array.strides[0]) ) + __pyx_t_23 * __pyx_v_source_array.strides[1]) ) + __pyx_t_24 * __pyx_v_source_array.strides[2]) ))));
3447:
+3448: if kernel_offset_x != 0:
__pyx_t_21 = ((__pyx_v_kernel_offset_x != 0) != 0); if (__pyx_t_21) { /* … */ }
3449:
+3450: r_gx = r_gx + <float> gray[0] * \
__pyx_v_r_gx = (__pyx_v_r_gx + (((float)(__pyx_v_gray[0])) * ((float)(*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_6shader_GX.data + __pyx_t_24 * __pyx_v_6shader_GX.strides[0]) )) + __pyx_t_23)) ))))));
+3451: <float> GX[kernel_offset_x + KERNEL_HALF,
if (unlikely(!__pyx_v_6shader_GX.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("GX"); __PYX_ERR(1, 3451, __pyx_L8_error) } /* … */ __pyx_t_24 = (__pyx_v_kernel_offset_x + __pyx_v_6shader_KERNEL_HALF); __pyx_t_23 = (__pyx_v_kernel_offset_y + __pyx_v_6shader_KERNEL_HALF);
3452: kernel_offset_y + KERNEL_HALF]
3453:
+3454: if kernel_offset_y != 0:
__pyx_t_21 = ((__pyx_v_kernel_offset_y != 0) != 0); if (__pyx_t_21) { /* … */ } } }
3455:
+3456: r_gy = r_gy + <float> gray[0] * \
__pyx_v_r_gy = (__pyx_v_r_gy + (((float)(__pyx_v_gray[0])) * ((float)(*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_6shader_GY.data + __pyx_t_23 * __pyx_v_6shader_GY.strides[0]) )) + __pyx_t_24)) ))))));
+3457: <float> GY[kernel_offset_x + KERNEL_HALF,
if (unlikely(!__pyx_v_6shader_GY.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("GY"); __PYX_ERR(1, 3457, __pyx_L8_error) } /* … */ __pyx_t_23 = (__pyx_v_kernel_offset_x + __pyx_v_6shader_KERNEL_HALF); __pyx_t_24 = (__pyx_v_kernel_offset_y + __pyx_v_6shader_KERNEL_HALF);
3458: kernel_offset_y + KERNEL_HALF]
3459:
+3460: magnitude = min(<float> sqrt(r_gx * r_gx + r_gy * r_gy), <float>255.0)
__pyx_t_14 = ((float)255.0); __pyx_t_13 = ((float)sqrt(((__pyx_v_r_gx * __pyx_v_r_gx) + (__pyx_v_r_gy * __pyx_v_r_gy)))); if (((__pyx_t_14 < __pyx_t_13) != 0)) { __pyx_t_25 = __pyx_t_14; } else { __pyx_t_25 = __pyx_t_13; } __pyx_v_magnitude = __pyx_t_25;
3461:
3462: # if magnitude > 255:
3463: # magnitude = 255.0
3464:
+3465: m = <unsigned char> magnitude if magnitude > threshold else 0
if (((__pyx_v_magnitude > __pyx_v_threshold) != 0)) { __pyx_t_26 = ((unsigned char)__pyx_v_magnitude); } else { __pyx_t_26 = 0; } __pyx_v_m = __pyx_t_26;
3466:
3467: # update the pixel if the magnitude is above threshold else black pixel
+3468: rgb_array[x, y, 0] = m
__pyx_t_24 = __pyx_v_x; __pyx_t_23 = __pyx_v_y; __pyx_t_22 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_24 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array.strides[2]) )) = __pyx_v_m;
+3469: rgb_array[x, y, 1] = m
__pyx_t_22 = __pyx_v_x; __pyx_t_23 = __pyx_v_y; __pyx_t_24 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_22 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_24 * __pyx_v_rgb_array.strides[2]) )) = __pyx_v_m;
+3470: rgb_array[x, y, 2] = m
__pyx_t_24 = __pyx_v_x; __pyx_t_23 = __pyx_v_y; __pyx_t_22 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_24 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array.strides[2]) )) = __pyx_v_m; } goto __pyx_L23; __pyx_L8_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L22; __pyx_L22:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates0) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_gray; __pyx_parallel_temp1 = __pyx_v_kernel_offset_x; __pyx_parallel_temp2 = __pyx_v_kernel_offset_y; __pyx_parallel_temp3 = __pyx_v_m; __pyx_parallel_temp4 = __pyx_v_magnitude; __pyx_parallel_temp5 = __pyx_v_r_gx; __pyx_parallel_temp6 = __pyx_v_r_gy; __pyx_parallel_temp7 = __pyx_v_x; __pyx_parallel_temp8 = __pyx_v_xx; __pyx_parallel_temp9 = __pyx_v_y; __pyx_parallel_temp10 = __pyx_v_yy; } __pyx_L23:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_gray = __pyx_parallel_temp0; __pyx_v_kernel_offset_x = __pyx_parallel_temp1; __pyx_v_kernel_offset_y = __pyx_parallel_temp2; __pyx_v_m = __pyx_parallel_temp3; __pyx_v_magnitude = __pyx_parallel_temp4; __pyx_v_r_gx = __pyx_parallel_temp5; __pyx_v_r_gy = __pyx_parallel_temp6; __pyx_v_x = __pyx_parallel_temp7; __pyx_v_xx = __pyx_parallel_temp8; __pyx_v_y = __pyx_parallel_temp9; __pyx_v_yy = __pyx_parallel_temp10; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L4_error; } } } #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 }
3471:
3472:
3473:
3474: @cython.boundscheck(False)
3475: @cython.wraparound(False)
3476: @cython.nonecheck(False)
3477: @cython.cdivision(True)
+3478: cdef unsigned char [:, :, ::1] scale_array24_c(
static __Pyx_memviewslice __pyx_f_6shader_scale_array24_c(__Pyx_memviewslice __pyx_v_rgb_array, int __pyx_v_w2, int __pyx_v_h2) { Py_ssize_t __pyx_v_w1; Py_ssize_t __pyx_v_h1; CYTHON_UNUSED Py_ssize_t __pyx_v_s; CYTHON_UNUSED PyObject *__pyx_v_e = NULL; __Pyx_memviewslice __pyx_v_new_array = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_fx; float __pyx_v_fy; int __pyx_v_x; int __pyx_v_y; Py_ssize_t __pyx_v_xx; Py_ssize_t __pyx_v_yy; __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("scale_array24_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_14); __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("shader.scale_array24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __Pyx_XDECREF(__pyx_v_e); __PYX_XDEC_MEMVIEW(&__pyx_v_new_array, 1); __Pyx_RefNannyFinishContext(); return __pyx_r; }
3479: unsigned char [:, :, :]
3480: rgb_array,
3481: int w2,
3482: int h2
3483: ):
3484: """
3485: ARRAY RE-SCALING ; ARRAY SHAPE (W, H, 3)
3486:
3487: This is an internal tool that cannot be access outside of this library (cpdef hook missing)
3488: Re-scale an array (rgb_array) of size (w, h, 3) into an equivalent array size (w2, h2, 3).
3489: This function is identical to a surface rescaling but uses the array instead
3490:
3491: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3492: please refer to pygame function pixels3d or array3d to convert an image into a 3d
3493: array (library surfarray)
3494:
3495: e.g:
3496: memview_array = scale_array24_c(my_array, 300, 300)
3497:
3498: :param rgb_array : RGB numpy.ndarray, format (w, h, 3) numpy.uint8
3499: :param w2 : new width
3500: :param h2 : new height
3501: :return : Return a MemoryViewSlice 3d numpy.ndarray format (w, h, 3) uint8
3502: """
+3503: assert w2 > 0, "Argument w2 cannot be <=0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_w2 > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_w2_cannot_be_0); __PYX_ERR(1, 3503, __pyx_L1_error) } } #endif
+3504: assert h2 > 0, "Argument h2 cannot be <=0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_h2 > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_h2_cannot_be_0); __PYX_ERR(1, 3504, __pyx_L1_error) } } #endif
3505:
3506: cdef Py_ssize_t w1, h1, s
3507:
+3508: try:
{ /*try:*/ { /* … */ } }
+3509: w1, h1, s = rgb_array.shape[:3]
__pyx_t_4 = __pyx_v_rgb_array.shape; __pyx_t_5 = (__pyx_t_4[0]); __pyx_t_6 = (__pyx_t_4[1]); __pyx_t_7 = (__pyx_t_4[2]); __pyx_v_w1 = __pyx_t_5; __pyx_v_h1 = __pyx_t_6; __pyx_v_s = __pyx_t_7;
3510:
3511: except (ValueError, pygame.error) as e:
3512: raise ValueError('\nArray shape not understood.')
3513:
3514: cdef:
+3515: unsigned char [:, :, ::1] new_array = numpy.zeros((w2, h2, 3), numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_numpy); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_zeros); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_w2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_h2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_int_3); __pyx_t_9 = 0; __pyx_t_11 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_uint8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_13 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_13 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_12, __pyx_t_9}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_11, __pyx_t_12, __pyx_t_9}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_13, 2+__pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); if (__pyx_t_11) { __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_11); __pyx_t_11 = NULL; } __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_9); __pyx_t_12 = 0; __pyx_t_9 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_15.memview)) __PYX_ERR(1, 3515, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_new_array = __pyx_t_15; __pyx_t_15.memview = NULL; __pyx_t_15.data = NULL;
+3516: float fx = <float>w1 / <float>w2
__pyx_v_fx = (((float)__pyx_v_w1) / ((float)__pyx_v_w2));
+3517: float fy = <float>h1 / <float>h2
__pyx_v_fy = (((float)__pyx_v_h1) / ((float)__pyx_v_h2));
3518: int x, y
3519: Py_ssize_t xx, yy
+3520: 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_L11; } __pyx_L11:; } }
+3521: for x in prange(w2, schedule='static', num_threads=THREADS):
__pyx_t_13 = __pyx_v_w2; 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_17 = (__pyx_t_13 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_17 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_13 = __pyx_v_w2; 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_17 = (__pyx_t_13 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_17 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_17; __pyx_t_16++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_16); /* Initialize private variables to invalid values */ __pyx_v_xx = ((Py_ssize_t)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((Py_ssize_t)0xbad0bad0);
+3522: xx = <int>(x * fx)
__pyx_v_xx = ((int)(__pyx_v_x * __pyx_v_fx));
+3523: for y in range(h2):
__pyx_t_18 = __pyx_v_h2; __pyx_t_19 = __pyx_t_18; for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_y = __pyx_t_20;
+3524: yy = <int>(y * fy)
__pyx_v_yy = ((int)(__pyx_v_y * __pyx_v_fy));
+3525: new_array[x, y, 0] = rgb_array[xx, yy, 0]
__pyx_t_21 = __pyx_v_xx; __pyx_t_22 = __pyx_v_yy; __pyx_t_23 = 0; __pyx_t_24 = __pyx_v_x; __pyx_t_25 = __pyx_v_y; __pyx_t_26 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_24 * __pyx_v_new_array.strides[0]) ) + __pyx_t_25 * __pyx_v_new_array.strides[1]) )) + __pyx_t_26)) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_21 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_22 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array.strides[2]) )));
+3526: new_array[x, y, 1] = rgb_array[xx, yy, 1]
__pyx_t_23 = __pyx_v_xx; __pyx_t_22 = __pyx_v_yy; __pyx_t_21 = 1; __pyx_t_26 = __pyx_v_x; __pyx_t_25 = __pyx_v_y; __pyx_t_24 = 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_25 * __pyx_v_new_array.strides[1]) )) + __pyx_t_24)) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_23 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_22 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_21 * __pyx_v_rgb_array.strides[2]) )));
+3527: new_array[x, y, 2] = rgb_array[xx, yy, 2]
__pyx_t_21 = __pyx_v_xx; __pyx_t_22 = __pyx_v_yy; __pyx_t_23 = 2; __pyx_t_24 = __pyx_v_x; __pyx_t_25 = __pyx_v_y; __pyx_t_26 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_24 * __pyx_v_new_array.strides[0]) ) + __pyx_t_25 * __pyx_v_new_array.strides[1]) )) + __pyx_t_26)) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_21 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_22 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array.strides[2]) ))); } } } } } } #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 }
3528:
+3529: return new_array
__PYX_INC_MEMVIEW(&__pyx_v_new_array, 0); __pyx_r = __pyx_v_new_array; goto __pyx_L0;
3530:
3531:
3532: @cython.boundscheck(False)
3533: @cython.wraparound(False)
3534: @cython.nonecheck(False)
3535: @cython.cdivision(True)
+3536: cdef inline void shader_sobel24_fast_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_sobel24_fast_inplace_c(PyObject *__pyx_v_surface_, struct __pyx_opt_args_6shader_shader_sobel24_fast_inplace_c *__pyx_optional_args) { int __pyx_v_threshold_ = ((int)20); unsigned short __pyx_v_factor_ = ((unsigned short)1); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; Py_ssize_t __pyx_v_w_1; Py_ssize_t __pyx_v_h_1; int __pyx_v_kernel_offset_x; int __pyx_v_kernel_offset_y; int __pyx_v_x; int __pyx_v_y; Py_ssize_t __pyx_v_xx; Py_ssize_t __pyx_v_yy; float __pyx_v_r_gx; float __pyx_v_r_gy; unsigned char *__pyx_v_gray; unsigned char __pyx_v_m; float __pyx_v_magnitude; __Pyx_memviewslice __pyx_v_source_array = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_rescale_array = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_new_array = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_new_ = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_sobel24_fast_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold_ = __pyx_optional_args->threshold_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_factor_ = __pyx_optional_args->factor_; } } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1); __Pyx_WriteUnraisable("shader.shader_sobel24_fast_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_source_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_rescale_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_new_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_new_, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_sobel24_fast_inplace_c { int __pyx_n; int threshold_; unsigned short factor_; };
3537: surface_, int threshold_=20, unsigned short factor_=1):
3538: """
3539: SHADER FAST SOBEL (EDGE DETECTION)
3540:
3541: Transform the game display or a pygame surface into a sobel equivalent model
3542: (surface edge detection).This version is slightly fastest than shader_sobel24_inplace_c as
3543: it down-scale the array containing all the pixels and apply the sobel algorithm to a smaller
3544: sample. When the processing is done, the array is re-scale to its original dimensions.
3545: If this method is in theory faster than shader_sobel24_inplace_c, down-scaling and up-scaling
3546: an array does have a side effect of decreasing the overall image definition
3547: (jagged lines non-antialiasing)
3548:
3549: e.g:
3550: sobel_fast(surface, 64, factor_=1)
3551:
3552: :param surface_ : pygame.Surface
3553: :param threshold_ : integer; threshold value for the sobel filter
3554: :param factor_ : unsigned short (default value =1). Define the
3555: reduction factor of an image. 1 divide by 2, 2 divide by 4 etc
3556: :return : void
3557: """
3558:
3559: cdef:
3560: Py_ssize_t w, h, w_1, h_1
+3561: w, h = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 3561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 3561, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 3561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 3561, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 3561, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 3561, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 3561, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
3562:
3563: cdef:
3564: int kernel_offset_x, kernel_offset_y
3565: int x, y
3566: Py_ssize_t xx, yy
3567: float r_gx, r_gy
3568: unsigned char *gray
3569: unsigned char m
3570: float magnitude
3571:
+3572: unsigned char [:, :, :] source_array = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3572, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_source_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
3573: unsigned char [:, :, :] rescale_array = \
+3574: numpy.array(pixels3d(scale(surface_, (w >> factor_, h >> factor_))))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_scale); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PyInt_FromSsize_t((__pyx_v_w >> __pyx_v_factor_)); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = PyInt_FromSsize_t((__pyx_v_h >> __pyx_v_factor_)); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_14 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_14 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_surface_, __pyx_t_13}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_surface_, __pyx_t_13}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { __pyx_t_11 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_12) { __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL; } __Pyx_INCREF(__pyx_v_surface_); __Pyx_GIVEREF(__pyx_v_surface_); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_14, __pyx_v_surface_); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_14, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_10, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3574, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rescale_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+3575: unsigned char [:, :, :] new_array = empty((w >> factor_, h >> factor_, 3), uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_w >> __pyx_v_factor_)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_h >> __pyx_v_factor_)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_int_3); __pyx_t_3 = 0; __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; __pyx_t_14 = 0; 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_14 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_9, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_9, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_14, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_14, __pyx_t_4); __pyx_t_9 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3575, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_new_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
3576:
+3577: h = h >> factor_
__pyx_v_h = (__pyx_v_h >> __pyx_v_factor_);
+3578: w = w >> factor_
__pyx_v_w = (__pyx_v_w >> __pyx_v_factor_);
+3579: w_1 = w - 1
__pyx_v_w_1 = (__pyx_v_w - 1);
+3580: h_1 = h - 1
__pyx_v_h_1 = (__pyx_v_h - 1);
3581:
+3582: 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_L7; } __pyx_L6_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L7:; } }
3583:
+3584: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_7 = __pyx_v_h; 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_15 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_15 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_gray) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_m) lastprivate(__pyx_v_magnitude) lastprivate(__pyx_v_r_gx) lastprivate(__pyx_v_r_gy) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_7 = __pyx_v_h; 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_15 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_15 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_gray) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_m) lastprivate(__pyx_v_magnitude) lastprivate(__pyx_v_r_gx) lastprivate(__pyx_v_r_gy) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_15; __pyx_t_6++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_6); /* Initialize private variables to invalid values */ __pyx_v_gray = ((unsigned char *)1); __pyx_v_kernel_offset_x = ((int)0xbad0bad0); __pyx_v_kernel_offset_y = ((int)0xbad0bad0); __pyx_v_m = ((unsigned char)'?'); __pyx_v_magnitude = ((float)__PYX_NAN()); __pyx_v_r_gx = ((float)__PYX_NAN()); __pyx_v_r_gy = ((float)__PYX_NAN()); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_xx = ((Py_ssize_t)0xbad0bad0); __pyx_v_yy = ((Py_ssize_t)0xbad0bad0);
3585:
+3586: for x in range(w):
__pyx_t_16 = __pyx_v_w; __pyx_t_17 = __pyx_t_16; for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_17; __pyx_t_14+=1) { __pyx_v_x = __pyx_t_14;
3587:
+3588: r_gx, r_gy = <float>0.0, <float>0.0
__pyx_t_18 = ((float)0.0); __pyx_t_19 = ((float)0.0); __pyx_v_r_gx = __pyx_t_18; __pyx_v_r_gy = __pyx_t_19;
3589:
+3590: for kernel_offset_y in range(-KERNEL_HALF, KERNEL_HALF + 1):
__pyx_t_20 = (__pyx_v_6shader_KERNEL_HALF + 1); __pyx_t_21 = __pyx_t_20; for (__pyx_t_22 = (-__pyx_v_6shader_KERNEL_HALF); __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) { __pyx_v_kernel_offset_y = __pyx_t_22;
3591:
+3592: for kernel_offset_x in range(-KERNEL_HALF, KERNEL_HALF + 1):
__pyx_t_23 = (__pyx_v_6shader_KERNEL_HALF + 1); __pyx_t_24 = __pyx_t_23; for (__pyx_t_25 = (-__pyx_v_6shader_KERNEL_HALF); __pyx_t_25 < __pyx_t_24; __pyx_t_25+=1) { __pyx_v_kernel_offset_x = __pyx_t_25;
3593:
+3594: xx = x + kernel_offset_x
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset_x);
+3595: yy = y + kernel_offset_y
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset_y);
3596:
+3597: if xx > w_1:
__pyx_t_26 = ((__pyx_v_xx > __pyx_v_w_1) != 0); if (__pyx_t_26) { /* … */ }
+3598: xx = w_1
__pyx_v_xx = __pyx_v_w_1;
+3599: if xx < 0:
__pyx_t_26 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_26) { /* … */ }
+3600: xx = 0
__pyx_v_xx = 0;
3601:
+3602: if yy > h_1:
__pyx_t_26 = ((__pyx_v_yy > __pyx_v_h_1) != 0); if (__pyx_t_26) { /* … */ }
+3603: yy = h_1
__pyx_v_yy = __pyx_v_h_1;
+3604: if yy < 0:
__pyx_t_26 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_26) { /* … */ }
+3605: yy = 0
__pyx_v_yy = 0;
3606:
3607: # grayscale image red = green = blue
+3608: gray = &rescale_array[xx, yy, 0]
__pyx_t_27 = __pyx_v_xx; __pyx_t_28 = __pyx_v_yy; __pyx_t_29 = 0; __pyx_v_gray = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rescale_array.data + __pyx_t_27 * __pyx_v_rescale_array.strides[0]) ) + __pyx_t_28 * __pyx_v_rescale_array.strides[1]) ) + __pyx_t_29 * __pyx_v_rescale_array.strides[2]) ))));
3609:
+3610: if kernel_offset_x != 0:
__pyx_t_26 = ((__pyx_v_kernel_offset_x != 0) != 0); if (__pyx_t_26) { /* … */ }
3611:
+3612: r_gx = r_gx + <float> gray[0] * \
__pyx_v_r_gx = (__pyx_v_r_gx + (((float)(__pyx_v_gray[0])) * ((float)(*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_6shader_GX.data + __pyx_t_29 * __pyx_v_6shader_GX.strides[0]) )) + __pyx_t_28)) ))))));
+3613: <float> GX[kernel_offset_x + KERNEL_HALF,
if (unlikely(!__pyx_v_6shader_GX.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("GX"); __PYX_ERR(1, 3613, __pyx_L10_error) } /* … */ __pyx_t_29 = (__pyx_v_kernel_offset_x + __pyx_v_6shader_KERNEL_HALF); __pyx_t_28 = (__pyx_v_kernel_offset_y + __pyx_v_6shader_KERNEL_HALF);
3614: kernel_offset_y + KERNEL_HALF]
3615:
+3616: if kernel_offset_y != 0:
__pyx_t_26 = ((__pyx_v_kernel_offset_y != 0) != 0); if (__pyx_t_26) { /* … */ } } }
3617:
+3618: r_gy = r_gy + <float> gray[0] * \
__pyx_v_r_gy = (__pyx_v_r_gy + (((float)(__pyx_v_gray[0])) * ((float)(*((short *) ( /* dim=1 */ ((char *) (((short *) ( /* dim=0 */ (__pyx_v_6shader_GY.data + __pyx_t_28 * __pyx_v_6shader_GY.strides[0]) )) + __pyx_t_29)) ))))));
+3619: <float> GY[kernel_offset_x + KERNEL_HALF,
if (unlikely(!__pyx_v_6shader_GY.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("GY"); __PYX_ERR(1, 3619, __pyx_L10_error) } /* … */ __pyx_t_28 = (__pyx_v_kernel_offset_x + __pyx_v_6shader_KERNEL_HALF); __pyx_t_29 = (__pyx_v_kernel_offset_y + __pyx_v_6shader_KERNEL_HALF);
3620: kernel_offset_y + KERNEL_HALF]
3621:
+3622: magnitude = <float> sqrt(r_gx * r_gx + r_gy * r_gy)
__pyx_v_magnitude = ((float)sqrt(((__pyx_v_r_gx * __pyx_v_r_gx) + (__pyx_v_r_gy * __pyx_v_r_gy))));
3623:
+3624: if magnitude > 255:
__pyx_t_26 = ((__pyx_v_magnitude > 255.0) != 0); if (__pyx_t_26) { /* … */ }
+3625: magnitude = <float>255.0
__pyx_v_magnitude = ((float)255.0);
3626:
+3627: m = <unsigned char> magnitude if magnitude > threshold_ else 0
if (((__pyx_v_magnitude > __pyx_v_threshold_) != 0)) { __pyx_t_30 = ((unsigned char)__pyx_v_magnitude); } else { __pyx_t_30 = 0; } __pyx_v_m = __pyx_t_30;
3628:
3629: # update the pixel if the magnitude is above threshold else black pixel
+3630: new_array[x, y, 0] = m
__pyx_t_29 = __pyx_v_x; __pyx_t_28 = __pyx_v_y; __pyx_t_27 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_29 * __pyx_v_new_array.strides[0]) ) + __pyx_t_28 * __pyx_v_new_array.strides[1]) ) + __pyx_t_27 * __pyx_v_new_array.strides[2]) )) = __pyx_v_m;
+3631: new_array[x, y, 1] = m
__pyx_t_27 = __pyx_v_x; __pyx_t_28 = __pyx_v_y; __pyx_t_29 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_27 * __pyx_v_new_array.strides[0]) ) + __pyx_t_28 * __pyx_v_new_array.strides[1]) ) + __pyx_t_29 * __pyx_v_new_array.strides[2]) )) = __pyx_v_m;
+3632: new_array[x, y, 2] = m
__pyx_t_29 = __pyx_v_x; __pyx_t_28 = __pyx_v_y; __pyx_t_27 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_29 * __pyx_v_new_array.strides[0]) ) + __pyx_t_28 * __pyx_v_new_array.strides[1]) ) + __pyx_t_27 * __pyx_v_new_array.strides[2]) )) = __pyx_v_m; } goto __pyx_L26; __pyx_L10_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L25; __pyx_L25:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates1) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_gray; __pyx_parallel_temp1 = __pyx_v_kernel_offset_x; __pyx_parallel_temp2 = __pyx_v_kernel_offset_y; __pyx_parallel_temp3 = __pyx_v_m; __pyx_parallel_temp4 = __pyx_v_magnitude; __pyx_parallel_temp5 = __pyx_v_r_gx; __pyx_parallel_temp6 = __pyx_v_r_gy; __pyx_parallel_temp7 = __pyx_v_x; __pyx_parallel_temp8 = __pyx_v_xx; __pyx_parallel_temp9 = __pyx_v_y; __pyx_parallel_temp10 = __pyx_v_yy; } __pyx_L26:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_gray = __pyx_parallel_temp0; __pyx_v_kernel_offset_x = __pyx_parallel_temp1; __pyx_v_kernel_offset_y = __pyx_parallel_temp2; __pyx_v_m = __pyx_parallel_temp3; __pyx_v_magnitude = __pyx_parallel_temp4; __pyx_v_r_gx = __pyx_parallel_temp5; __pyx_v_r_gy = __pyx_parallel_temp6; __pyx_v_x = __pyx_parallel_temp7; __pyx_v_xx = __pyx_parallel_temp8; __pyx_v_y = __pyx_parallel_temp9; __pyx_v_yy = __pyx_parallel_temp10; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L6_error; } } } #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 }
3633:
+3634: w = w << factor_
__pyx_v_w = (__pyx_v_w << __pyx_v_factor_);
+3635: h = h << factor_
__pyx_v_h = (__pyx_v_h << __pyx_v_factor_);
3636:
+3637: cdef unsigned char [:, :, :] new_ = scale_array24_c(new_array, w, h)
__pyx_t_31 = __pyx_f_6shader_scale_array24_c(__pyx_v_new_array, __pyx_v_w, __pyx_v_h); if (unlikely(!__pyx_t_31.memview)) __PYX_ERR(1, 3637, __pyx_L1_error)
__pyx_v_new_ = __pyx_t_31;
__pyx_t_31.memview = NULL;
__pyx_t_31.data = NULL;
3638:
+3639: 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_L29; } __pyx_L29:; } }
3640:
+3641: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_15 = __pyx_v_h; 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_7 = (__pyx_t_15 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_7 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_15 = __pyx_v_h; 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_7 = (__pyx_t_15 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_7 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_7; __pyx_t_6++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_6); /* Initialize private variables to invalid values */ __pyx_v_x = ((int)0xbad0bad0);
+3642: for x in range(w):
__pyx_t_16 = __pyx_v_w; __pyx_t_17 = __pyx_t_16; for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_17; __pyx_t_14+=1) { __pyx_v_x = __pyx_t_14;
3643:
+3644: source_array[x, y, 0] = new_[x, y, 0]
__pyx_t_27 = __pyx_v_x; __pyx_t_28 = __pyx_v_y; __pyx_t_29 = 0; __pyx_t_32 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_32 * __pyx_v_source_array.strides[0]) ) + __pyx_t_33 * __pyx_v_source_array.strides[1]) ) + __pyx_t_34 * __pyx_v_source_array.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_.data + __pyx_t_27 * __pyx_v_new_.strides[0]) ) + __pyx_t_28 * __pyx_v_new_.strides[1]) ) + __pyx_t_29 * __pyx_v_new_.strides[2]) )));
+3645: source_array[x, y, 1] = new_[x, y, 1]
__pyx_t_29 = __pyx_v_x; __pyx_t_28 = __pyx_v_y; __pyx_t_27 = 1; __pyx_t_34 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_32 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_34 * __pyx_v_source_array.strides[0]) ) + __pyx_t_33 * __pyx_v_source_array.strides[1]) ) + __pyx_t_32 * __pyx_v_source_array.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_.data + __pyx_t_29 * __pyx_v_new_.strides[0]) ) + __pyx_t_28 * __pyx_v_new_.strides[1]) ) + __pyx_t_27 * __pyx_v_new_.strides[2]) )));
+3646: source_array[x, y, 2] = new_[x, y, 2]
__pyx_t_27 = __pyx_v_x; __pyx_t_28 = __pyx_v_y; __pyx_t_29 = 2; __pyx_t_32 = __pyx_v_x; __pyx_t_33 = __pyx_v_y; __pyx_t_34 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_32 * __pyx_v_source_array.strides[0]) ) + __pyx_t_33 * __pyx_v_source_array.strides[1]) ) + __pyx_t_34 * __pyx_v_source_array.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_.data + __pyx_t_27 * __pyx_v_new_.strides[0]) ) + __pyx_t_28 * __pyx_v_new_.strides[1]) ) + __pyx_t_29 * __pyx_v_new_.strides[2]) ))); } } } } } } #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 }
3647:
3648:
3649: @cython.boundscheck(False)
3650: @cython.wraparound(False)
3651: @cython.nonecheck(False)
3652: @cython.cdivision(True)
+3653: cdef inline void shader_invert_surface_24bit_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_invert_surface_24bit_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_invert_surface_24bit_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
3654: unsigned char [:, :, :] rgb_array):
3655:
3656: """
3657: SHADER INVERT PIXELS
3658:
3659: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3660: please refer to pygame function pixels3d or array3d to convert an image into a 3d
3661: array (library surfarray)
3662:
3663: Invert all pixels of the display or a given texture
3664: e.g:
3665: invert(surface)
3666:
3667: :param rgb_array : numpy.ndarray containing all the RGB color values. Array shape (w, h, 3)
3668: :return : void
3669: """
3670:
3671: cdef Py_ssize_t w, h
+3672: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3673:
3674: cdef:
+3675: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
3676: unsigned char *r
3677: unsigned char *g
3678: unsigned char *b
3679:
+3680: 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:; } }
+3681: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1);
+3682: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
+3683: r = &rgb_array[i, j, 0]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+3684: g = &rgb_array[i, j, 1]
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+3685: b = &rgb_array[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+3686: r[0] = 255 - r[0]
(__pyx_v_r[0]) = (0xFF - (__pyx_v_r[0]));
+3687: g[0] = 255 - g[0]
(__pyx_v_g[0]) = (0xFF - (__pyx_v_g[0]));
+3688: b[0] = 255 - b[0]
(__pyx_v_b[0]) = (0xFF - (__pyx_v_b[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 }
3689:
3690:
+3691: cdef float[5] GAUSS_KERNEL = [1.0/16.0, 4.0/16.0, 6.0/16.0, 4.0/16.0, 1.0/16.0]
__pyx_t_36[0] = (1.0 / 16.0); __pyx_t_36[1] = (4.0 / 16.0); __pyx_t_36[2] = (6.0 / 16.0); __pyx_t_36[3] = (4.0 / 16.0); __pyx_t_36[4] = (1.0 / 16.0); memcpy(&(__pyx_v_6shader_GAUSS_KERNEL[0]), __pyx_t_36, sizeof(__pyx_v_6shader_GAUSS_KERNEL[0]) * (5));
3692:
3693: @cython.boundscheck(False)
3694: @cython.wraparound(False)
3695: @cython.nonecheck(False)
3696: @cython.cdivision(True)
+3697: cdef inline void shader_blur5x5_array24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_blur5x5_array24_inplace_c *__pyx_optional_args) { PyObject *__pyx_v_t = ((PyObject *)__pyx_int_1); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; short __pyx_v_kernel_half; __Pyx_memviewslice __pyx_v_convolve = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED __Pyx_memviewslice __pyx_v_convolved = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED Py_ssize_t __pyx_v_kernel_length; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; char __pyx_v_kernel_offset; unsigned char __pyx_v_red; unsigned char __pyx_v_green; unsigned char __pyx_v_blue; float *__pyx_v_k; unsigned char *__pyx_v_c1; unsigned char *__pyx_v_c2; unsigned char *__pyx_v_c3; unsigned char *__pyx_v_c4; unsigned char *__pyx_v_c5; unsigned char *__pyx_v_c6; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_blur5x5_array24_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_t = __pyx_optional_args->t; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_blur5x5_array24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_convolve, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_convolved, 1); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_blur5x5_array24_inplace_c { int __pyx_n; PyObject *mask; PyObject *t; };
3698: unsigned char [:, :, :] rgb_array_, mask=None, t=1):
3699: """
3700: APPLY A GAUSSIAN BLUR EFFECT TO THE GAME DISPLAY OR TO A GIVEN TEXTURE (KERNEL 5x5)
3701:
3702: # Gaussian kernel 5x5
3703: # |1 4 6 4 1|
3704: # |4 16 24 16 4|
3705: # |6 24 36 24 6| x 1/256
3706: # |4 16 24 16 4|
3707: # |1 4 6 4 1|
3708: This method is using convolution property and process the image in two passes,
3709: first the horizontal convolution and last the vertical convolution
3710: pixels convoluted outside image edges will be set to adjacent edge value
3711:
3712: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3713: please refer to pygame function pixels3d or array3d to convert an image into a 3d array (
3714: library surfarray)
3715:
3716: :param rgb_array_ : numpy.ndarray type (w, h, 3) uint8
3717: :param mask : numpy.ndarray default None
3718: :param t : integer; number of times
3719: :return : Return 24-bit a numpy.ndarray type (w, h, 3) uint8
3720: """
3721:
3722: cdef Py_ssize_t w, h
+3723: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3724:
3725: # kernel 5x5 separable
3726: cdef:
3727:
+3728: short int kernel_half = 2
__pyx_v_kernel_half = 2;
+3729: unsigned char [:, :, ::1] convolve = numpy.empty((w, h, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_3); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3729, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_convolve = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+3730: unsigned char [:, :, ::1] convolved = numpy.empty((w, h, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_3); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3730, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_convolved = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+3731: Py_ssize_t kernel_length = len(GAUSS_KERNEL)
__pyx_t_4 = __Pyx_carray_to_py_float(__pyx_v_6shader_GAUSS_KERNEL, 5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 3731, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_kernel_length = __pyx_t_3;
3732: int x, y, xx, yy
3733: float r, g, b, s
3734: char kernel_offset
3735: unsigned char red, green, blue
3736: float *k
3737: unsigned char *c1
3738: unsigned char *c2
3739: unsigned char *c3
3740: unsigned char *c4
3741: unsigned char *c5
3742: unsigned char *c6
3743:
+3744: for r in range(t):
__pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_t); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0; __pyx_t_9 = NULL; } else { __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 3744, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_5))) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 3744, __pyx_L1_error) #else __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 3744, __pyx_L1_error) #else __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(1, 3744, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __pyx_t_10 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_10 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 3744, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_r = __pyx_t_10; /* … */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+3745: 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_L9; } __pyx_L9:; } }
3746:
3747: # horizontal convolution
+3748: for y in prange(0, h, schedule='static', num_threads=THREADS):
__pyx_t_2 = __pyx_v_h; 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_2 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_c3) lastprivate(__pyx_v_c4) lastprivate(__pyx_v_c5) lastprivate(__pyx_v_c6) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_2 = __pyx_v_h; 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_2 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_c3) lastprivate(__pyx_v_c4) lastprivate(__pyx_v_c5) lastprivate(__pyx_v_c6) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_11); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_c1 = ((unsigned char *)1); __pyx_v_c2 = ((unsigned char *)1); __pyx_v_c3 = ((unsigned char *)1); __pyx_v_c4 = ((unsigned char *)1); __pyx_v_c5 = ((unsigned char *)1); __pyx_v_c6 = ((unsigned char *)1); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float *)1); __pyx_v_kernel_offset = ((char)'?'); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0);
3749:
+3750: c1 = &rgb_array_[0, y, 0]
__pyx_t_13 = 0; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; __pyx_v_c1 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
+3751: c2 = &rgb_array_[0, y, 1]
__pyx_t_15 = 0; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; __pyx_v_c2 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) ))));
+3752: c3 = &rgb_array_[0, y, 2]
__pyx_t_13 = 0; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 2; __pyx_v_c3 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
+3753: c4 = &rgb_array_[w-1, y, 0]
__pyx_t_15 = (__pyx_v_w - 1); __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 0; __pyx_v_c4 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) ))));
+3754: c5 = &rgb_array_[w-1, y, 1]
__pyx_t_13 = (__pyx_v_w - 1); __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 1; __pyx_v_c5 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
+3755: c6 = &rgb_array_[w-1, y, 2]
__pyx_t_15 = (__pyx_v_w - 1); __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 2; __pyx_v_c6 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) ))));
3756:
+3757: for x in range(0, w): # range [0..w-1]
__pyx_t_16 = __pyx_v_w; __pyx_t_17 = __pyx_t_16; for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_x = __pyx_t_18;
3758:
+3759: r, g, b = 0, 0, 0
__pyx_t_10 = 0.0; __pyx_t_19 = 0.0; __pyx_t_20 = 0.0; __pyx_v_r = __pyx_t_10; __pyx_v_g = __pyx_t_19; __pyx_v_b = __pyx_t_20;
3760:
+3761: for kernel_offset in range(-kernel_half, kernel_half + 1):
__pyx_t_21 = (__pyx_v_kernel_half + 1); __pyx_t_22 = __pyx_t_21; for (__pyx_t_23 = (-__pyx_v_kernel_half); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_kernel_offset = __pyx_t_23;
3762:
+3763: k = &GAUSS_KERNEL[kernel_offset + kernel_half]
__pyx_v_k = (&(__pyx_v_6shader_GAUSS_KERNEL[(__pyx_v_kernel_offset + __pyx_v_kernel_half)]));
3764:
+3765: xx = x + kernel_offset
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset);
3766:
3767: # check boundaries.
3768: # Fetch the edge pixel for the convolution
+3769: if xx < 0:
__pyx_t_24 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_24) { /* … */ goto __pyx_L18; }
+3770: red, green, blue = c1[0], c2[0], c3[0]
__pyx_t_25 = (__pyx_v_c1[0]); __pyx_t_26 = (__pyx_v_c2[0]); __pyx_t_27 = (__pyx_v_c3[0]); __pyx_v_red = __pyx_t_25; __pyx_v_green = __pyx_t_26; __pyx_v_blue = __pyx_t_27;
+3771: elif xx > (w - 1):
__pyx_t_24 = ((__pyx_v_xx > (__pyx_v_w - 1)) != 0); if (__pyx_t_24) { /* … */ goto __pyx_L18; }
+3772: red, green, blue = c4[0], c5[0], c6[0]
__pyx_t_27 = (__pyx_v_c4[0]); __pyx_t_26 = (__pyx_v_c5[0]); __pyx_t_25 = (__pyx_v_c6[0]); __pyx_v_red = __pyx_t_27; __pyx_v_green = __pyx_t_26; __pyx_v_blue = __pyx_t_25;
3773: else:
+3774: red, green, blue = rgb_array_[xx, y, 0],\
/*else*/ { __pyx_t_13 = __pyx_v_xx; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; __pyx_t_25 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )));
+3775: rgb_array_[xx, y, 1], rgb_array_[xx, y, 2]
__pyx_t_15 = __pyx_v_xx; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; __pyx_t_26 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_13 = __pyx_v_xx; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 2; __pyx_t_27 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_25; __pyx_v_green = __pyx_t_26; __pyx_v_blue = __pyx_t_27;
+3776: if red + green + blue == 0:
__pyx_t_24 = ((((__pyx_v_red + __pyx_v_green) + __pyx_v_blue) == 0) != 0); if (__pyx_t_24) { /* … */ } } __pyx_L18:;
+3777: continue
goto __pyx_L16_continue;
3778:
+3779: r = r + red * k[0]
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * (__pyx_v_k[0])));
+3780: g = g + green * k[0]
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * (__pyx_v_k[0])));
+3781: b = b + blue * k[0]
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * (__pyx_v_k[0]))); __pyx_L16_continue:; }
3782:
+3783: convolve[x, y, 0] = <unsigned char>r
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_15 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_13)) )) = ((unsigned char)__pyx_v_r);
+3784: convolve[x, y, 1] = <unsigned char>g
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_13 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_15)) )) = ((unsigned char)__pyx_v_g);
+3785: convolve[x, y, 2] = <unsigned char>b
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_15 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_13)) )) = ((unsigned char)__pyx_v_b); } } } } } } #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
3786:
3787: # Vertical convolution
+3788: for x in prange(0, w, schedule='static', num_threads=THREADS):
__pyx_t_12 = __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_2 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_2 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_c3) lastprivate(__pyx_v_c4) lastprivate(__pyx_v_c5) lastprivate(__pyx_v_c6) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_12 = __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_2 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_2 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_c3) lastprivate(__pyx_v_c4) lastprivate(__pyx_v_c5) lastprivate(__pyx_v_c6) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_2; __pyx_t_11++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_11); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned char)'?'); __pyx_v_c1 = ((unsigned char *)1); __pyx_v_c2 = ((unsigned char *)1); __pyx_v_c3 = ((unsigned char *)1); __pyx_v_c4 = ((unsigned char *)1); __pyx_v_c5 = ((unsigned char *)1); __pyx_v_c6 = ((unsigned char *)1); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned char)'?'); __pyx_v_k = ((float *)1); __pyx_v_kernel_offset = ((char)'?'); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned char)'?'); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
3789:
+3790: c1 = &convolve[x, 0, 0]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_v_c1 = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_13 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_15)) ))));
+3791: c2 = &convolve[x, 0, 1]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = 0; __pyx_t_13 = 1; __pyx_v_c2 = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_15 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_13)) ))));
+3792: c3 = &convolve[x, 0, 2]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = 0; __pyx_t_15 = 2; __pyx_v_c3 = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_13 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_15)) ))));
+3793: c4 = &convolve[x, h-1, 0]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = (__pyx_v_h - 1); __pyx_t_13 = 0; __pyx_v_c4 = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_15 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_13)) ))));
+3794: c5 = &convolve[x, h-1, 1]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_h - 1); __pyx_t_15 = 1; __pyx_v_c5 = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_13 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_15)) ))));
+3795: c6 = &convolve[x, h-1, 2]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = (__pyx_v_h - 1); __pyx_t_13 = 2; __pyx_v_c6 = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_15 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_13)) ))));
3796:
+3797: for y in range(0, h):
__pyx_t_16 = __pyx_v_h; __pyx_t_17 = __pyx_t_16; for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_y = __pyx_t_18;
+3798: r, g, b = 0, 0, 0
__pyx_t_20 = 0.0; __pyx_t_19 = 0.0; __pyx_t_10 = 0.0; __pyx_v_r = __pyx_t_20; __pyx_v_g = __pyx_t_19; __pyx_v_b = __pyx_t_10;
3799:
+3800: for kernel_offset in range(-kernel_half, kernel_half + 1):
__pyx_t_21 = (__pyx_v_kernel_half + 1); __pyx_t_22 = __pyx_t_21; for (__pyx_t_23 = (-__pyx_v_kernel_half); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_kernel_offset = __pyx_t_23;
3801:
+3802: k = &GAUSS_KERNEL[kernel_offset + kernel_half]
__pyx_v_k = (&(__pyx_v_6shader_GAUSS_KERNEL[(__pyx_v_kernel_offset + __pyx_v_kernel_half)]));
+3803: yy = y + kernel_offset
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset);
3804:
+3805: if yy < 0:
__pyx_t_24 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_24) { /* … */ goto __pyx_L30; }
+3806: red, green, blue = c1[0], c2[0], c3[0]
__pyx_t_27 = (__pyx_v_c1[0]); __pyx_t_26 = (__pyx_v_c2[0]); __pyx_t_25 = (__pyx_v_c3[0]); __pyx_v_red = __pyx_t_27; __pyx_v_green = __pyx_t_26; __pyx_v_blue = __pyx_t_25;
+3807: elif yy > (h -1):
__pyx_t_24 = ((__pyx_v_yy > (__pyx_v_h - 1)) != 0); if (__pyx_t_24) { /* … */ goto __pyx_L30; }
+3808: red, green, blue = c4[0], c5[0], c6[0]
__pyx_t_25 = (__pyx_v_c4[0]); __pyx_t_26 = (__pyx_v_c5[0]); __pyx_t_27 = (__pyx_v_c6[0]); __pyx_v_red = __pyx_t_25; __pyx_v_green = __pyx_t_26; __pyx_v_blue = __pyx_t_27;
3809: else:
+3810: red, green, blue = convolve[x, yy, 0],\
/*else*/ { __pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_yy; __pyx_t_15 = 0; __pyx_t_27 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_13 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_15)) )));
+3811: convolve[x, yy, 1], convolve[x, yy, 2]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_yy; __pyx_t_13 = 1; __pyx_t_26 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_15 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_13)) ))); __pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_yy; __pyx_t_15 = 2; __pyx_t_25 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_convolve.data + __pyx_t_13 * __pyx_v_convolve.strides[0]) ) + __pyx_t_14 * __pyx_v_convolve.strides[1]) )) + __pyx_t_15)) ))); __pyx_v_red = __pyx_t_27; __pyx_v_green = __pyx_t_26; __pyx_v_blue = __pyx_t_25;
+3812: if red + green + blue == 0:
__pyx_t_24 = ((((__pyx_v_red + __pyx_v_green) + __pyx_v_blue) == 0) != 0); if (__pyx_t_24) { /* … */ } } __pyx_L30:;
+3813: continue
goto __pyx_L28_continue;
3814:
+3815: r = r + red * k[0]
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * (__pyx_v_k[0])));
+3816: g = g + green * k[0]
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * (__pyx_v_k[0])));
+3817: b = b + blue * k[0]
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * (__pyx_v_k[0]))); __pyx_L28_continue:; }
3818:
+3819: rgb_array_[x, y, 0], rgb_array_[x, y, 1], rgb_array_[x, y, 2] = \
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_25; __pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_26; __pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_27; } } } } } } #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 }
+3820: <unsigned char>r, <unsigned char>g, <unsigned char>b
__pyx_t_25 = ((unsigned char)__pyx_v_r); __pyx_t_26 = ((unsigned char)__pyx_v_g); __pyx_t_27 = ((unsigned char)__pyx_v_b);
3821:
3822:
3823: @cython.boundscheck(False)
3824: @cython.wraparound(False)
3825: @cython.nonecheck(False)
3826: @cython.cdivision(True)
+3827: cdef inline void shader_wave24bit_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_wave24bit_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_rad, int __pyx_v_size) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_x_pos; int __pyx_v_y_pos; int __pyx_v_xx; int __pyx_v_yy; int __pyx_v_i; int __pyx_v_j; float __pyx_v_c1; int __pyx_v_w_1; int __pyx_v_h_1; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_wave24bit_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_wave24bit_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1); __Pyx_RefNannyFinishContext(); }
3828: unsigned char [:, :, :] rgb_array_,
3829: float rad,
3830: int size):
3831: """
3832: CREATE A WAVE EFFECT TO THE GAME DISPLAY OR TO A GIVEN SURFACE
3833:
3834: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3835: please refer to pygame function pixels3d or array3d to convert an image into a
3836: 3d array (library surfarray)
3837:
3838: e.g:
3839: wave(surface, 8 * math.pi/180.0 + frame_number, 5)
3840:
3841: :param rgb_array_ : numpy.ndarray shape (w, h, 3) containing all the RGB values
3842: :param rad : float; angle in rad to rotate over time
3843: :param size : int; Number of sub-surfaces
3844: :return : void
3845: """
3846:
3847:
3848:
3849: cdef Py_ssize_t w, h
+3850: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3851:
3852: cdef:
+3853: unsigned char [:, :, :] rgb = numpy.array(rgb_array_, copy=True)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3853, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3853, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
3854: int x, y, x_pos, y_pos, xx, yy
+3855: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
+3856: float c1 = <float>1.0 / <float>(size * size)
__pyx_v_c1 = (((float)1.0) / ((float)(__pyx_v_size * __pyx_v_size)));
+3857: int w_1 = <int>w - 1
__pyx_v_w_1 = (((int)__pyx_v_w) - 1);
+3858: int h_1 = <int>h - 1
__pyx_v_h_1 = (((int)__pyx_v_h) - 1);
3859:
+3860: 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:; } }
3861:
+3862: for y in prange(0, h_1 - size, size, schedule='static', num_threads=THREADS):
__pyx_t_9 = (__pyx_v_h_1 - __pyx_v_size); __pyx_t_10 = __pyx_v_size; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x_pos) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y_pos) lastprivate(__pyx_v_yy) schedule(static) __pyx_t_10 = __pyx_v_size; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x_pos) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y_pos) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){ { __pyx_v_y = (int)(0 + __pyx_t_10 * __pyx_t_11); /* Initialize private variables to invalid values */ __pyx_v_i = ((int)0xbad0bad0); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_x_pos = ((int)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_y_pos = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
3863:
+3864: y_pos = y + size + <int>(<float>sin(rad + <float>y * c1) * <float>size)
__pyx_v_y_pos = ((__pyx_v_y + __pyx_v_size) + ((int)(((float)sin((__pyx_v_rad + (((float)__pyx_v_y) * __pyx_v_c1)))) * ((float)__pyx_v_size))));
3865:
+3866: for x in prange(0, w_1 - size, size, schedule='static', num_threads=THREADS):
__pyx_t_13 = (__pyx_v_w_1 - __pyx_v_size); __pyx_t_14 = __pyx_v_size; if ((__pyx_t_14 == 0)) abort(); { __pyx_t_16 = (__pyx_t_13 - 0 + __pyx_t_14 - __pyx_t_14/abs(__pyx_t_14)) / __pyx_t_14; if (__pyx_t_16 > 0) { #if 0 #pragma omp parallel #endif /* _OPENMP */ { #if 0 #pragma omp for lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x_pos) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_yy) schedule(static) __pyx_t_14 = __pyx_v_size; if ((__pyx_t_14 == 0)) abort(); { __pyx_t_16 = (__pyx_t_13 - 0 + __pyx_t_14 - __pyx_t_14/abs(__pyx_t_14)) / __pyx_t_14; if (__pyx_t_16 > 0) { #if 0 #pragma omp parallel #endif /* _OPENMP */ { #if 0 #pragma omp for lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x_pos) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_16; __pyx_t_15++){ { __pyx_v_x = (int)(0 + __pyx_t_14 * __pyx_t_15); /* Initialize private variables to invalid values */ __pyx_v_i = ((int)0xbad0bad0); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_x_pos = ((int)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
3867:
+3868: x_pos = x + size + <int> (<float>sin(rad + <float> x * c1) * <float> size)
__pyx_v_x_pos = ((__pyx_v_x + __pyx_v_size) + ((int)(((float)sin((__pyx_v_rad + (((float)__pyx_v_x) * __pyx_v_c1)))) * ((float)__pyx_v_size))));
3869:
+3870: for i in range(0, size + 1):
__pyx_t_17 = (__pyx_v_size + 1); __pyx_t_18 = __pyx_t_17; for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) { __pyx_v_i = __pyx_t_19;
3871:
+3872: for j in range(0, size + 1):
__pyx_t_20 = (__pyx_v_size + 1); __pyx_t_21 = __pyx_t_20; for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) { __pyx_v_j = __pyx_t_22;
3873:
+3874: xx = x_pos + i
__pyx_v_xx = (__pyx_v_x_pos + __pyx_v_i);
+3875: yy = y_pos + j
__pyx_v_yy = (__pyx_v_y_pos + __pyx_v_j);
3876:
+3877: if xx > w_1:
__pyx_t_23 = ((__pyx_v_xx > __pyx_v_w_1) != 0); if (__pyx_t_23) { /* … */ goto __pyx_L18; }
+3878: xx = w_1
__pyx_v_xx = __pyx_v_w_1;
+3879: elif xx < 0:
__pyx_t_23 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_23) { /* … */ } __pyx_L18:;
+3880: xx = 0
__pyx_v_xx = 0;
+3881: if yy > h_1:
__pyx_t_23 = ((__pyx_v_yy > __pyx_v_h_1) != 0); if (__pyx_t_23) { /* … */ goto __pyx_L19; }
+3882: yy = h_1
__pyx_v_yy = __pyx_v_h_1;
+3883: elif yy < 0:
__pyx_t_23 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_23) { /* … */ } __pyx_L19:;
+3884: yy = 0
__pyx_v_yy = 0;
+3885: rgb_array_[xx, yy, 0] = rgb[x + i, y + j, 0]
__pyx_t_24 = (__pyx_v_x + __pyx_v_i); __pyx_t_25 = (__pyx_v_y + __pyx_v_j); __pyx_t_26 = 0; __pyx_t_27 = __pyx_v_xx; __pyx_t_28 = __pyx_v_yy; __pyx_t_29 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_27 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_28 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_29 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_24 * __pyx_v_rgb.strides[0]) ) + __pyx_t_25 * __pyx_v_rgb.strides[1]) ) + __pyx_t_26 * __pyx_v_rgb.strides[2]) )));
+3886: rgb_array_[xx, yy, 1] = rgb[x + i, y + j, 1]
__pyx_t_26 = (__pyx_v_x + __pyx_v_i); __pyx_t_25 = (__pyx_v_y + __pyx_v_j); __pyx_t_24 = 1; __pyx_t_29 = __pyx_v_xx; __pyx_t_28 = __pyx_v_yy; __pyx_t_27 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_29 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_28 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_27 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_26 * __pyx_v_rgb.strides[0]) ) + __pyx_t_25 * __pyx_v_rgb.strides[1]) ) + __pyx_t_24 * __pyx_v_rgb.strides[2]) )));
+3887: rgb_array_[xx, yy, 2] = rgb[x + i, y + j, 2]
__pyx_t_24 = (__pyx_v_x + __pyx_v_i); __pyx_t_25 = (__pyx_v_y + __pyx_v_j); __pyx_t_26 = 2; __pyx_t_27 = __pyx_v_xx; __pyx_t_28 = __pyx_v_yy; __pyx_t_29 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_27 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_28 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_29 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_24 * __pyx_v_rgb.strides[0]) ) + __pyx_t_25 * __pyx_v_rgb.strides[1]) ) + __pyx_t_26 * __pyx_v_rgb.strides[2]) ))); } } } } } } } } } } } } #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 }
3888:
3889:
3890:
3891:
3892: @cython.boundscheck(False)
3893: @cython.wraparound(False)
3894: @cython.nonecheck(False)
3895: @cython.cdivision(False)
+3896: cdef inline void shader_swirl24bit_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_swirl24bit_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_degrees) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; int __pyx_v_diffx; int __pyx_v_diffy; int __pyx_v_angle; float __pyx_v_columns; float __pyx_v_rows; float __pyx_v_r; float __pyx_v_di; float __pyx_v_dj; float __pyx_v_c1; float __pyx_v_c2; __Pyx_memviewslice __pyx_v_rgb = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_r_max; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_swirl24bit_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_swirl24bit_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1); __Pyx_RefNannyFinishContext(); }
3897: unsigned char [:, :, :] rgb_array_,
3898: float degrees
3899: ):
3900: """
3901: SWIRL AN IMAGE (ANGLE APPROXIMATION METHOD)
3902:
3903: This algorithm uses a table of cos and sin.
3904:
3905: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3906: please refer to pygame function pixels3d or array3d to convert an image into a
3907: 3d array (library surfarray)
3908:
3909: e.g:
3910: swirl(surface, frame_number / 1000.0)
3911:
3912: :param rgb_array_ : numpy.ndarray shape (w, h, 3) containing all the RGB color values
3913: :param degrees : float; swirl angle in degrees
3914: :return : void
3915: """
3916:
3917: cdef Py_ssize_t w, h
+3918: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3919:
3920: cdef:
3921: int i, j, diffx, diffy, angle
3922: float columns, rows, r, di, dj, c1, c2
+3923: unsigned char [:, :, ::1] rgb = numpy.array(rgb_array_, copy=True, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3923, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 3923, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3923, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
3924: float r_max
3925:
3926:
+3927: columns = <float>0.5 * (<float>w - <float>1.0)
__pyx_v_columns = (((float)0.5) * (((float)__pyx_v_w) - ((float)1.0)));
+3928: rows = <float>0.5 * (<float>h - <float>1.0)
__pyx_v_rows = (((float)0.5) * (((float)__pyx_v_h) - ((float)1.0)));
3929:
+3930: r_max = <float>sqrt(columns * columns + rows * rows)
__pyx_v_r_max = ((float)sqrt(((__pyx_v_columns * __pyx_v_columns) + (__pyx_v_rows * __pyx_v_rows))));
3931:
+3932: 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_L4_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L5:; } }
+3933: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_angle) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_di) lastprivate(__pyx_v_diffx) lastprivate(__pyx_v_diffy) lastprivate(__pyx_v_dj) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_angle) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_di) lastprivate(__pyx_v_diffx) lastprivate(__pyx_v_diffy) lastprivate(__pyx_v_dj) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_9; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_angle = ((int)0xbad0bad0); __pyx_v_c1 = ((float)__PYX_NAN()); __pyx_v_c2 = ((float)__PYX_NAN()); __pyx_v_di = ((float)__PYX_NAN()); __pyx_v_diffx = ((int)0xbad0bad0); __pyx_v_diffy = ((int)0xbad0bad0); __pyx_v_dj = ((float)__PYX_NAN()); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_r = ((float)__PYX_NAN());
+3934: for i in range(w):
__pyx_t_10 = __pyx_v_w; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_i = __pyx_t_12;
3935:
+3936: di = <float>i - columns
__pyx_v_di = (((float)__pyx_v_i) - __pyx_v_columns);
+3937: dj = <float>j - rows
__pyx_v_dj = (((float)__pyx_v_j) - __pyx_v_rows);
3938:
+3939: r = <float>sqrt(di * di + dj * dj) / <float>r_max
__pyx_t_13 = ((float)sqrt(((__pyx_v_di * __pyx_v_di) + (__pyx_v_dj * __pyx_v_dj)))); if (unlikely(((float)__pyx_v_r_max) == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "float division"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 3939, __pyx_L8_error) } __pyx_v_r = (__pyx_t_13 / ((float)__pyx_v_r_max));
+3940: angle = <int>(degrees * r % 360)
__pyx_v_angle = ((int)__Pyx_mod_float((__pyx_v_degrees * __pyx_v_r), 360.0));
3941:
+3942: c1 = COS_TABLE[angle]
__pyx_v_c1 = (__pyx_v_6shader_COS_TABLE[__pyx_v_angle]);
+3943: c2 = SIN_TABLE[angle]
__pyx_v_c2 = (__pyx_v_6shader_SIN_TABLE[__pyx_v_angle]);
+3944: diffx = <int>(di * c1 - dj * c2 + columns)
__pyx_v_diffx = ((int)(((__pyx_v_di * __pyx_v_c1) - (__pyx_v_dj * __pyx_v_c2)) + __pyx_v_columns));
+3945: diffy = <int>(di * c2 + dj * c1 + rows)
__pyx_v_diffy = ((int)(((__pyx_v_di * __pyx_v_c2) + (__pyx_v_dj * __pyx_v_c1)) + __pyx_v_rows));
3946:
+3947: if (diffx >-1) and (diffx < w) and \
__pyx_t_15 = ((__pyx_v_diffx > -1L) != 0); if (__pyx_t_15) { } else { __pyx_t_14 = __pyx_t_15; goto __pyx_L13_bool_binop_done; } __pyx_t_15 = ((__pyx_v_diffx < __pyx_v_w) != 0); if (__pyx_t_15) { } else { __pyx_t_14 = __pyx_t_15; goto __pyx_L13_bool_binop_done; } /* … */ if (__pyx_t_14) { /* … */ } } goto __pyx_L18; __pyx_L8_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L17; __pyx_L17:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates2) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_angle; __pyx_parallel_temp1 = __pyx_v_c1; __pyx_parallel_temp2 = __pyx_v_c2; __pyx_parallel_temp3 = __pyx_v_di; __pyx_parallel_temp4 = __pyx_v_diffx; __pyx_parallel_temp5 = __pyx_v_diffy; __pyx_parallel_temp6 = __pyx_v_dj; __pyx_parallel_temp7 = __pyx_v_i; __pyx_parallel_temp8 = __pyx_v_j; __pyx_parallel_temp9 = __pyx_v_r; } __pyx_L18:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_angle = __pyx_parallel_temp0; __pyx_v_c1 = __pyx_parallel_temp1; __pyx_v_c2 = __pyx_parallel_temp2; __pyx_v_di = __pyx_parallel_temp3; __pyx_v_diffx = __pyx_parallel_temp4; __pyx_v_diffy = __pyx_parallel_temp5; __pyx_v_dj = __pyx_parallel_temp6; __pyx_v_i = __pyx_parallel_temp7; __pyx_v_j = __pyx_parallel_temp8; __pyx_v_r = __pyx_parallel_temp9; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L4_error; } } } #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 }
+3948: (diffy >-1) and (diffy < h):
__pyx_t_15 = ((__pyx_v_diffy > -1L) != 0); if (__pyx_t_15) { } else { __pyx_t_14 = __pyx_t_15; goto __pyx_L13_bool_binop_done; } __pyx_t_15 = ((__pyx_v_diffy < __pyx_v_h) != 0); __pyx_t_14 = __pyx_t_15; __pyx_L13_bool_binop_done:;
+3949: rgb_array_[i, j, 0], rgb_array_[i, j, 1],\
__pyx_t_18 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_16 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_18 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_19; __pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_20;
+3950: rgb_array_[i, j, 2] = rgb[diffx, diffy, 0], \
__pyx_t_16 = __pyx_v_diffx; __pyx_t_17 = __pyx_v_diffy; __pyx_t_18 = 0; __pyx_t_19 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_16 * __pyx_v_rgb.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb.strides[1]) )) + __pyx_t_18)) ))); /* … */ __pyx_t_18 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_16 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_18 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_21;
+3951: rgb[diffx, diffy, 1], rgb[diffx, diffy, 2]
__pyx_t_18 = __pyx_v_diffx; __pyx_t_17 = __pyx_v_diffy; __pyx_t_16 = 1; __pyx_t_20 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_18 * __pyx_v_rgb.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb.strides[1]) )) + __pyx_t_16)) ))); __pyx_t_16 = __pyx_v_diffx; __pyx_t_17 = __pyx_v_diffy; __pyx_t_18 = 2; __pyx_t_21 = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_16 * __pyx_v_rgb.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb.strides[1]) )) + __pyx_t_18)) )));
3952:
3953:
3954: @cython.boundscheck(False)
3955: @cython.wraparound(False)
3956: @cython.nonecheck(False)
3957: @cython.cdivision(True)
+3958: cdef inline void shader_swirl24bit_inplace_c1(unsigned char [:, :, :] rgb_array_, float degrees):
static CYTHON_INLINE void __pyx_f_6shader_shader_swirl24bit_inplace_c1(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_degrees) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; int __pyx_v_diffx; int __pyx_v_diffy; float __pyx_v_columns; float __pyx_v_rows; float __pyx_v_r; float __pyx_v_di; float __pyx_v_dj; float __pyx_v_c1; float __pyx_v_c2; float __pyx_v_angle; __Pyx_memviewslice __pyx_v_rgb = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_rad; float __pyx_v_r_max; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_swirl24bit_inplace_c1", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_swirl24bit_inplace_c1", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1); __Pyx_RefNannyFinishContext(); }
3959: """
3960: SWIRL AN IMAGE WITHOUT ANGLE APPROXIMATION
3961:
3962: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
3963: please refer to pygame function pixels3d or array3d to convert an image into a 3d
3964: array (library surfarray)
3965:
3966: e.g:
3967: swirl(surface_, frame_number / 1000)
3968:
3969: :param rgb_array_ : numpy.ndarray shape (w, h, 3) containing all the RGB color values
3970: :param degrees : float; swirl angle in degrees
3971: :return : void
3972: """
3973:
3974: cdef Py_ssize_t w, h
+3975: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
3976:
3977: cdef:
3978: int i, j, diffx, diffy
3979: float columns, rows, r, di, dj, c1, c2, angle
+3980: unsigned char [:, :, :] rgb = numpy.array(rgb_array_, copy=True)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 3980, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 3980, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+3981: float rad = degrees * DEG_TO_RAD
__pyx_v_rad = (__pyx_v_degrees * __pyx_v_6shader_DEG_TO_RAD);
3982: float r_max
3983:
3984:
+3985: columns = <float>0.5 * (w - <float>1.0)
__pyx_v_columns = (((float)0.5) * (__pyx_v_w - ((float)1.0)));
+3986: rows = <float>0.5 * (h - <float>1.0)
__pyx_v_rows = (((float)0.5) * (__pyx_v_h - ((float)1.0)));
+3987: r_max = <float>sqrt(columns * columns + rows * rows)
__pyx_v_r_max = ((float)sqrt(((__pyx_v_columns * __pyx_v_columns) + (__pyx_v_rows * __pyx_v_rows))));
+3988: 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:; } }
+3989: for i in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_angle) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_di) lastprivate(__pyx_v_diffx) lastprivate(__pyx_v_diffy) lastprivate(__pyx_v_dj) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_angle) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_di) lastprivate(__pyx_v_diffx) lastprivate(__pyx_v_diffy) lastprivate(__pyx_v_dj) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_9; __pyx_t_2++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_angle = ((float)__PYX_NAN()); __pyx_v_c1 = ((float)__PYX_NAN()); __pyx_v_c2 = ((float)__PYX_NAN()); __pyx_v_di = ((float)__PYX_NAN()); __pyx_v_diffx = ((int)0xbad0bad0); __pyx_v_diffy = ((int)0xbad0bad0); __pyx_v_dj = ((float)__PYX_NAN()); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_r = ((float)__PYX_NAN());
+3990: for j in range(h):
__pyx_t_10 = __pyx_v_h; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_j = __pyx_t_12;
3991:
+3992: di = <float>i - columns
__pyx_v_di = (((float)__pyx_v_i) - __pyx_v_columns);
+3993: dj = <float>j - rows
__pyx_v_dj = (((float)__pyx_v_j) - __pyx_v_rows);
3994:
+3995: r = <float>sqrt(di * di + dj * dj)
__pyx_v_r = ((float)sqrt(((__pyx_v_di * __pyx_v_di) + (__pyx_v_dj * __pyx_v_dj))));
+3996: angle = <float>(rad * r/r_max)
__pyx_v_angle = ((float)((__pyx_v_rad * __pyx_v_r) / __pyx_v_r_max));
3997:
+3998: c1 = <float>cos(angle)
__pyx_v_c1 = ((float)cos(__pyx_v_angle));
+3999: c2 = <float>sin(angle)
__pyx_v_c2 = ((float)sin(__pyx_v_angle));
+4000: diffx = <int>(di * c1 - dj * c2 + columns)
__pyx_v_diffx = ((int)(((__pyx_v_di * __pyx_v_c1) - (__pyx_v_dj * __pyx_v_c2)) + __pyx_v_columns));
+4001: diffy = <int>(di * c2 + dj * c1 + rows)
__pyx_v_diffy = ((int)(((__pyx_v_di * __pyx_v_c2) + (__pyx_v_dj * __pyx_v_c1)) + __pyx_v_rows));
4002:
+4003: if (diffx >-1) and (diffx < w) and \
__pyx_t_14 = ((__pyx_v_diffx > -1L) != 0); if (__pyx_t_14) { } else { __pyx_t_13 = __pyx_t_14; goto __pyx_L13_bool_binop_done; } __pyx_t_14 = ((__pyx_v_diffx < __pyx_v_w) != 0); if (__pyx_t_14) { } else { __pyx_t_13 = __pyx_t_14; goto __pyx_L13_bool_binop_done; } /* … */ if (__pyx_t_13) { /* … */ } } } } } } } #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 }
+4004: (diffy >-1) and (diffy < h):
__pyx_t_14 = ((__pyx_v_diffy > -1L) != 0); if (__pyx_t_14) { } else { __pyx_t_13 = __pyx_t_14; goto __pyx_L13_bool_binop_done; } __pyx_t_14 = ((__pyx_v_diffy < __pyx_v_h) != 0); __pyx_t_13 = __pyx_t_14; __pyx_L13_bool_binop_done:;
+4005: rgb_array_[i, j, 0], rgb_array_[i, j, 1],\
__pyx_t_17 = __pyx_v_i; __pyx_t_16 = __pyx_v_j; __pyx_t_15 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_17 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_18; __pyx_t_15 = __pyx_v_i; __pyx_t_16 = __pyx_v_j; __pyx_t_17 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_19;
+4006: rgb_array_[i, j, 2] = rgb[diffx, diffy, 0], \
__pyx_t_15 = __pyx_v_diffx; __pyx_t_16 = __pyx_v_diffy; __pyx_t_17 = 0; __pyx_t_18 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_15 * __pyx_v_rgb.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb.strides[2]) ))); /* … */ __pyx_t_17 = __pyx_v_i; __pyx_t_16 = __pyx_v_j; __pyx_t_15 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_17 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_20;
+4007: rgb[diffx, diffy, 1], rgb[diffx, diffy, 2]
__pyx_t_17 = __pyx_v_diffx; __pyx_t_16 = __pyx_v_diffy; __pyx_t_15 = 1; __pyx_t_19 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_17 * __pyx_v_rgb.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb.strides[2]) ))); __pyx_t_15 = __pyx_v_diffx; __pyx_t_16 = __pyx_v_diffy; __pyx_t_17 = 2; __pyx_t_20 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_15 * __pyx_v_rgb.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb.strides[2]) )));
4008:
4009:
4010:
4011:
4012: @cython.boundscheck(False)
4013: @cython.wraparound(False)
4014: @cython.nonecheck(False)
4015: @cython.cdivision(False)
+4016: cdef inline void shader_plasma24bit_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_plasma24bit_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, int __pyx_v_frame, struct __pyx_opt_args_6shader_shader_plasma24bit_inplace_c *__pyx_optional_args) { float __pyx_v_hue_ = __pyx_k__19; float __pyx_v_sat_ = __pyx_k__20; float __pyx_v_value_ = __pyx_k__21; float __pyx_v_a_ = ((float)0.00392156862745098); float __pyx_v_b_ = ((float)0.08333333333333333); float __pyx_v_c_ = ((float)0.08333333333333333); CYTHON_UNUSED Py_ssize_t __pyx_v_width; Py_ssize_t __pyx_v_height; float __pyx_v_xx; float __pyx_v_yy; float __pyx_v_t; float __pyx_v_h; float __pyx_v_s; float __pyx_v_v; int __pyx_v_i; int __pyx_v_x; int __pyx_v_y; float __pyx_v_f; float __pyx_v_p; float __pyx_v_q; float __pyx_v_t_; float __pyx_v_hue; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; unsigned char *__pyx_v_rr; unsigned char *__pyx_v_gg; unsigned char *__pyx_v_bb; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_plasma24bit_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_hue_ = __pyx_optional_args->hue_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_sat_ = __pyx_optional_args->sat_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_value_ = __pyx_optional_args->value_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_a_ = __pyx_optional_args->a_; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_b_ = __pyx_optional_args->b_; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_c_ = __pyx_optional_args->c_; } } } } } } } /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_plasma24bit_inplace_c { int __pyx_n; float hue_; float sat_; float value_; float a_; float b_; float c_; };
4017: unsigned char [:, :, :] rgb_array_,
4018: int frame,
+4019: float hue_=1.0/6.0,
if (unlikely(6.0 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 4019, __pyx_L1_error) } __pyx_k__19 = (1.0 / 6.0);
+4020: float sat_=1.0/6.0,
if (unlikely(6.0 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 4020, __pyx_L1_error) } __pyx_k__20 = (1.0 / 6.0);
+4021: float value_=1.0/8.0,
if (unlikely(8.0 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 4021, __pyx_L1_error) } __pyx_k__21 = (1.0 / 8.0);
4022: float a_=ONE_255,
4023: float b_=ONE_TWELVE,
4024: float c_=ONE_TWELVE):
4025: """
4026: CREATE A BASIC PLASMA EFFECT ON THE TOP OF A PYGAME SURFACE
4027:
4028: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4029: please refer to pygame function pixels3d or array3d to convert an image into a
4030: 3d array (library surfarray)
4031:
4032: e.g:
4033: plasma_config(surface, frame_number)
4034:
4035: :param a_ : float; default value 1.0/255.0 control the plasma equation
4036: :param b_ : float; default value 1.0/12.0 control the plasma equation
4037: :param c_ : float; default value 1.0/12.0 control the plasma equation
4038: :param value_ : float; default value 1.0/8.0 value factor
4039: :param sat_ : float; default value 1.0/6.0 saturation value
4040: :param hue_ : float; default value 1.0/6.0 hue value factor
4041: :param rgb_array_ : numpy.ndarray shape( w, h, 3) containing all the RGB color values
4042: :param frame : integer; Variable that need to change over time
4043: :return : void
4044: """
4045:
4046: cdef Py_ssize_t width, height
+4047: width, height = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_width = __pyx_t_2; __pyx_v_height = __pyx_t_3;
4048:
4049: cdef:
4050: float xx, yy, t
4051: float h, s, v
+4052: int i = 0, x, y
__pyx_v_i = 0;
4053: float f, p, q, t_
4054: float hue, r, g, b
4055: unsigned char *rr
4056: unsigned char *gg
4057: unsigned char *bb
4058:
+4059: t = <float>frame
__pyx_v_t = ((float)__pyx_v_frame);
4060:
+4061: 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:; } }
+4062: for x in prange(width, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_f) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_h) lastprivate(__pyx_v_hue) lastprivate(__pyx_v_i) lastprivate(__pyx_v_p) lastprivate(__pyx_v_q) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_s) lastprivate(__pyx_v_t_) lastprivate(__pyx_v_v) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_3 = __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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_f) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_h) lastprivate(__pyx_v_hue) lastprivate(__pyx_v_i) lastprivate(__pyx_v_p) lastprivate(__pyx_v_q) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_s) lastprivate(__pyx_v_t_) lastprivate(__pyx_v_v) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_bb = ((unsigned char *)1); __pyx_v_f = ((float)__PYX_NAN()); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_gg = ((unsigned char *)1); __pyx_v_h = ((float)__PYX_NAN()); __pyx_v_hue = ((float)__PYX_NAN()); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_p = ((float)__PYX_NAN()); __pyx_v_q = ((float)__PYX_NAN()); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_rr = ((unsigned char *)1); __pyx_v_s = ((float)__PYX_NAN()); __pyx_v_t_ = ((float)__PYX_NAN()); __pyx_v_v = ((float)__PYX_NAN()); __pyx_v_xx = ((float)__PYX_NAN()); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((float)__PYX_NAN());
+4063: for y in range(height):
__pyx_t_5 = __pyx_v_height; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_y = __pyx_t_7;
4064:
+4065: xx = <float>x * <float>0.5
__pyx_v_xx = (((float)__pyx_v_x) * ((float)0.5));
+4066: yy = <float>y * <float>0.5
__pyx_v_yy = (((float)__pyx_v_y) * ((float)0.5));
4067:
4068: hue = <float>4.0 + <float>sin((xx * <float>0.5 + yy * <float>0.5) * a_) \
+4069: + <float>sin((xx * b_ + t) * c_)
__pyx_v_hue = ((((float)4.0) + ((float)sin((((__pyx_v_xx * ((float)0.5)) + (__pyx_v_yy * ((float)0.5))) * __pyx_v_a_)))) + ((float)sin((((__pyx_v_xx * __pyx_v_b_) + __pyx_v_t) * __pyx_v_c_))));
4070:
+4071: h, s, v = hue * hue_, hue * sat_, hue * value_
__pyx_t_8 = (__pyx_v_hue * __pyx_v_hue_); __pyx_t_9 = (__pyx_v_hue * __pyx_v_sat_); __pyx_t_10 = (__pyx_v_hue * __pyx_v_value_); __pyx_v_h = __pyx_t_8; __pyx_v_s = __pyx_t_9; __pyx_v_v = __pyx_t_10;
4072:
+4073: i = <int>(h * <float>6.0)
__pyx_v_i = ((int)(__pyx_v_h * ((float)6.0)));
+4074: f = (h * <float>6.0) - i
__pyx_v_f = ((__pyx_v_h * ((float)6.0)) - __pyx_v_i);
+4075: p = v*(<float>1.0 - s)
__pyx_v_p = (__pyx_v_v * (((float)1.0) - __pyx_v_s));
+4076: q = v*(<float>1.0 - s * f)
__pyx_v_q = (__pyx_v_v * (((float)1.0) - (__pyx_v_s * __pyx_v_f)));
+4077: t_ = v*(<float>1.0 - s * (<float>1.0 - f))
__pyx_v_t_ = (__pyx_v_v * (((float)1.0) - (__pyx_v_s * (((float)1.0) - __pyx_v_f))));
+4078: i = i % 6
__pyx_v_i = __Pyx_mod_long(__pyx_v_i, 6);
4079:
+4080: if i == 0:
__pyx_t_11 = ((__pyx_v_i == 0) != 0); if (__pyx_t_11) { /* … */ }
+4081: r, g, b = v, t, p
__pyx_t_10 = __pyx_v_v; __pyx_t_9 = __pyx_v_t; __pyx_t_8 = __pyx_v_p; __pyx_v_r = __pyx_t_10; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_8;
+4082: if i == 1:
__pyx_t_11 = ((__pyx_v_i == 1) != 0); if (__pyx_t_11) { /* … */ }
+4083: r, g, b = q, v, p
__pyx_t_8 = __pyx_v_q; __pyx_t_9 = __pyx_v_v; __pyx_t_10 = __pyx_v_p; __pyx_v_r = __pyx_t_8; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_10;
+4084: if i == 2:
__pyx_t_11 = ((__pyx_v_i == 2) != 0); if (__pyx_t_11) { /* … */ }
+4085: r, g, b = p, v, t
__pyx_t_10 = __pyx_v_p; __pyx_t_9 = __pyx_v_v; __pyx_t_8 = __pyx_v_t; __pyx_v_r = __pyx_t_10; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_8;
+4086: if i == 3:
__pyx_t_11 = ((__pyx_v_i == 3) != 0); if (__pyx_t_11) { /* … */ }
+4087: r, g, b = p, q, v
__pyx_t_8 = __pyx_v_p; __pyx_t_9 = __pyx_v_q; __pyx_t_10 = __pyx_v_v; __pyx_v_r = __pyx_t_8; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_10;
+4088: if i == 4:
__pyx_t_11 = ((__pyx_v_i == 4) != 0); if (__pyx_t_11) { /* … */ }
+4089: r, g, b = t_, p, v
__pyx_t_10 = __pyx_v_t_; __pyx_t_9 = __pyx_v_p; __pyx_t_8 = __pyx_v_v; __pyx_v_r = __pyx_t_10; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_8;
+4090: if i == 5:
__pyx_t_11 = ((__pyx_v_i == 5) != 0); if (__pyx_t_11) { /* … */ }
+4091: r, g, b = v, p, q
__pyx_t_8 = __pyx_v_v; __pyx_t_9 = __pyx_v_p; __pyx_t_10 = __pyx_v_q; __pyx_v_r = __pyx_t_8; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_10;
4092:
+4093: if s == 0.0:
__pyx_t_11 = ((__pyx_v_s == 0.0) != 0); if (__pyx_t_11) { /* … */ }
+4094: r, g, b = v, v, v
__pyx_t_10 = __pyx_v_v; __pyx_t_9 = __pyx_v_v; __pyx_t_8 = __pyx_v_v; __pyx_v_r = __pyx_t_10; __pyx_v_g = __pyx_t_9; __pyx_v_b = __pyx_t_8;
4095:
+4096: rr = &rgb_array_[x, y, 0]
__pyx_t_12 = __pyx_v_x; __pyx_t_13 = __pyx_v_y; __pyx_t_14 = 0; __pyx_v_rr = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) ))));
+4097: gg = &rgb_array_[x, y, 1]
__pyx_t_14 = __pyx_v_x; __pyx_t_13 = __pyx_v_y; __pyx_t_12 = 1; __pyx_v_gg = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))));
+4098: bb = &rgb_array_[x, y, 2]
__pyx_t_12 = __pyx_v_x; __pyx_t_13 = __pyx_v_y; __pyx_t_14 = 2; __pyx_v_bb = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) ))));
4099:
+4100: if rr[0] < 256:
__pyx_t_11 = (((__pyx_v_rr[0]) < 0x100) != 0); if (__pyx_t_11) { /* … */ }
+4101: rr[0] = <unsigned char>(min(rr[0] + r * <float>128.0, <float>255.0))
__pyx_t_8 = ((float)255.0); __pyx_t_9 = ((__pyx_v_rr[0]) + (__pyx_v_r * ((float)128.0))); if (((__pyx_t_8 < __pyx_t_9) != 0)) { __pyx_t_10 = __pyx_t_8; } else { __pyx_t_10 = __pyx_t_9; } (__pyx_v_rr[0]) = ((unsigned char)__pyx_t_10);
4102:
+4103: if gg[0] < 256:
__pyx_t_11 = (((__pyx_v_gg[0]) < 0x100) != 0); if (__pyx_t_11) { /* … */ }
+4104: gg[0] = <unsigned char>(min(gg[0] + g * <float>128.0, <float>255.0))
__pyx_t_10 = ((float)255.0); __pyx_t_8 = ((__pyx_v_gg[0]) + (__pyx_v_g * ((float)128.0))); if (((__pyx_t_10 < __pyx_t_8) != 0)) { __pyx_t_9 = __pyx_t_10; } else { __pyx_t_9 = __pyx_t_8; } (__pyx_v_gg[0]) = ((unsigned char)__pyx_t_9);
4105:
+4106: if bb[0] < 256:
__pyx_t_11 = (((__pyx_v_bb[0]) < 0x100) != 0); if (__pyx_t_11) { /* … */ } } } } } } } #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 }
+4107: bb[0] = <unsigned char>(min(bb[0] + b * <float>128.0, <float>255.0))
__pyx_t_9 = ((float)255.0); __pyx_t_10 = ((__pyx_v_bb[0]) + (__pyx_v_b * ((float)128.0))); if (((__pyx_t_9 < __pyx_t_10) != 0)) { __pyx_t_8 = __pyx_t_9; } else { __pyx_t_8 = __pyx_t_10; } (__pyx_v_bb[0]) = ((unsigned char)__pyx_t_8);
4108:
4109:
4110: @cython.boundscheck(False)
4111: @cython.wraparound(False)
4112: @cython.nonecheck(False)
4113: @cython.cdivision(True)
+4114: cdef inline void shader_plasma_c(surface_, float frame, unsigned int [::1] palette_):
static CYTHON_INLINE void __pyx_f_6shader_shader_plasma_c(PyObject *__pyx_v_surface_, float __pyx_v_frame, __Pyx_memviewslice __pyx_v_palette_) { Py_ssize_t __pyx_v_width; Py_ssize_t __pyx_v_height; int __pyx_v_x; int __pyx_v_y; int __pyx_v_ii; int __pyx_v_c; __Pyx_memviewslice __pyx_v_rgb_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned char *__pyx_v_rr; unsigned char *__pyx_v_gg; unsigned char *__pyx_v_bb; float __pyx_v_color_; float __pyx_v_w2; float __pyx_v_h2; Py_ssize_t __pyx_v_length; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_plasma_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_plasma_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_, 1); __Pyx_RefNannyFinishContext(); }
4115:
4116: """
4117: CREATE A PLASMA EFFECT INPLACE
4118:
4119: e.g:
4120: plasma(surface, frame_number)
4121:
4122: :param surface_: pygame Surface
4123: :param frame : float; frame number
4124: :param palette_: color palette
4125: :return : void
4126: """
4127: cdef Py_ssize_t width, height
+4128: width, height = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 4128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 4128, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 4128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 4128, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 4128, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 4128, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 4128, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_width = __pyx_t_6; __pyx_v_height = __pyx_t_7;
4129:
4130: cdef:
4131: int x, y, ii,c
4132:
+4133: unsigned char [:, :, :] rgb_array_ = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 4133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rgb_array_ = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
4134:
4135: unsigned char *rr
4136: unsigned char *gg
4137: unsigned char *bb
4138: float color_
+4139: float w2 = <float>width * <float>HALF
__pyx_v_w2 = (((float)__pyx_v_width) * ((float)0.5));
+4140: float h2 = <float>height * <float>HALF
__pyx_v_h2 = (((float)__pyx_v_height) * ((float)0.5));
+4141: Py_ssize_t length = len(palette_)
__pyx_t_9 = __Pyx_MemoryView_Len(__pyx_v_palette_);
__pyx_v_length = __pyx_t_9;
4142:
+4143: 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_L7; } __pyx_L7:; } }
4144:
+4145: for y in prange(height, schedule='static', num_threads=THREADS):
__pyx_t_7 = __pyx_v_height; 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_10 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_bb) lastprivate(__pyx_v_c) lastprivate(__pyx_v_color_) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_7 = __pyx_v_height; 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_10 = (__pyx_t_7 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_bb) lastprivate(__pyx_v_c) lastprivate(__pyx_v_color_) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_10; __pyx_t_6++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_6); /* Initialize private variables to invalid values */ __pyx_v_bb = ((unsigned char *)1); __pyx_v_c = ((int)0xbad0bad0); __pyx_v_color_ = ((float)__PYX_NAN()); __pyx_v_gg = ((unsigned char *)1); __pyx_v_ii = ((int)0xbad0bad0); __pyx_v_rr = ((unsigned char *)1); __pyx_v_x = ((int)0xbad0bad0);
+4146: for x in range(width):
__pyx_t_11 = __pyx_v_width; __pyx_t_12 = __pyx_t_11; for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_x = __pyx_t_13;
4147:
+4148: rr = &rgb_array_[x, y, 0]
__pyx_t_14 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_16 = 0; __pyx_v_rr = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) ))));
+4149: gg = &rgb_array_[x, y, 1]
__pyx_t_16 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_14 = 1; __pyx_v_gg = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) ))));
+4150: bb = &rgb_array_[x, y, 2]
__pyx_t_14 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_16 = 2; __pyx_v_bb = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) ))));
4151:
4152: color_ = <float>128.0 + (<float>128.0 * <float>sin(x * ONE_255 + frame)) \
4153: + <float>128.0 + (<float>128.0 * <float>sin(frame * ONE_32 + y * ONE_64)) \
4154: + <float>128.0 + (<float>128.0 * <float>sin(
4155: sqrt((x - w2) * (x - w2) + (y - h2) * (y - h2)) * ONE_255)) \
+4156: + <float>128.0 + (<float>128.0 * <float>sin(
__pyx_v_color_ = (((((((((float)128.0) + (((float)128.0) * ((float)sin(((__pyx_v_x * 0.00392156862745098) + __pyx_v_frame))))) + ((float)128.0)) + (((float)128.0) * ((float)sin(((__pyx_v_frame * 0.03125) + (__pyx_v_y * 0.015625)))))) + ((float)128.0)) + (((float)128.0) * ((float)sin((sqrt((((__pyx_v_x - __pyx_v_w2) * (__pyx_v_x - __pyx_v_w2)) + ((__pyx_v_y - __pyx_v_h2) * (__pyx_v_y - __pyx_v_h2)))) * 0.00392156862745098))))) + ((float)128.0)) + (((float)128.0) * ((float)sin((((float)sqrt((((__pyx_v_x * __pyx_v_x) + (__pyx_v_y * __pyx_v_y)) + __pyx_v_frame))) * ((float)0.015625))))));
4157: <float>sqrt(x * x + y * y + frame) * <float>ONE_64))
4158:
+4159: c = min(<int>(color_ / <float>8.0), <int>length)
__pyx_t_17 = ((int)__pyx_v_length); __pyx_t_18 = ((int)(__pyx_v_color_ / ((float)8.0))); if (((__pyx_t_17 < __pyx_t_18) != 0)) { __pyx_t_19 = __pyx_t_17; } else { __pyx_t_19 = __pyx_t_18; } __pyx_v_c = __pyx_t_19;
4160:
+4161: ii = palette_[c]
__pyx_t_16 = __pyx_v_c; __pyx_v_ii = (*((unsigned int *) ( /* dim=0 */ ((char *) (((unsigned int *) __pyx_v_palette_.data) + __pyx_t_16)) )));
4162:
+4163: rr[0] = (ii >> 16) & 255
(__pyx_v_rr[0]) = ((__pyx_v_ii >> 16) & 0xFF);
+4164: gg[0] = (ii >> 8) & 255
(__pyx_v_gg[0]) = ((__pyx_v_ii >> 8) & 0xFF);
+4165: bb[0] = ii & 255
(__pyx_v_bb[0]) = (__pyx_v_ii & 0xFF); } } } } } } #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 }
4166:
4167:
4168: @cython.boundscheck(False)
4169: @cython.wraparound(False)
4170: @cython.nonecheck(False)
4171: @cython.cdivision(True)
+4172: cdef inline float [:, :, :, ::1] rgb_to_hsl_model_c():
static CYTHON_INLINE __Pyx_memviewslice __pyx_f_6shader_rgb_to_hsl_model_c(void) { __Pyx_memviewslice __pyx_v_rgb_to_hsl = { 0, 0, { 0 }, { 0 }, { 0 } }; struct hsl __pyx_v_hsl_; int __pyx_v_r; int __pyx_v_g; int __pyx_v_b; __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_hsl_model_c", 0); /* … */ /* 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_6); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("shader.rgb_to_hsl_model_c", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_to_hsl, 1); __Pyx_RefNannyFinishContext(); return __pyx_r; }
4173: """
4174: CONVERT RGB INTO HSL MODEL
4175:
4176: The array can be used when the rgb to hsl is extensively used
4177:
4178: All the values will be stored into an array shape (r, g, b, 3) type float
4179: :return: Numpy.ndarray shape (r, g, b, 3) type float
4180: """
+4181: cdef float [:, :, :, ::1] rgb_to_hsl = numpy.empty((256, 256, 256, 3), float32)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_tuple__22, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_tuple__22, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_tuple__22); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rgb_to_hsl = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; /* … */ __pyx_tuple__22 = PyTuple_Pack(4, __pyx_int_256, __pyx_int_256, __pyx_int_256, __pyx_int_3); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 4181, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22);
4182: cdef hsl hsl_
4183: cdef int r, g, b
+4184: 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:; } }
+4185: for r in prange(0, 256, schedule='static', num_threads=THREADS):
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_9 = (0x100 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) firstprivate(__pyx_v_r) lastprivate(__pyx_v_r) schedule(static) /* … */ 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_9 = (0x100 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) firstprivate(__pyx_v_r) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_9; __pyx_t_8++){ { __pyx_v_r = (int)(0 + 1 * __pyx_t_8); /* Initialize private variables to invalid values */ __pyx_v_b = ((int)0xbad0bad0); __pyx_v_g = ((int)0xbad0bad0);
+4186: for g in range(0, 256):
for (__pyx_t_5 = 0; __pyx_t_5 < 0x100; __pyx_t_5+=1) { __pyx_v_g = __pyx_t_5;
+4187: for b in range(0, 256):
for (__pyx_t_10 = 0; __pyx_t_10 < 0x100; __pyx_t_10+=1) { __pyx_v_b = __pyx_t_10;
+4188: hsl_ = struct_rgb_to_hsl(
__pyx_v_hsl_ = struct_rgb_to_hsl((__pyx_v_r * ((float)0.00392156862745098)), (__pyx_v_g * ((float)0.00392156862745098)), (__pyx_v_b * ((float)0.00392156862745098)));
4189: r * <float>ONE_255, g * <float>ONE_255, b * <float>ONE_255)
+4190: rgb_to_hsl[r, g, b, 0] = min(<float>(hsl_.h * <float>255.0), <float>255.0)
__pyx_t_11 = ((float)255.0); __pyx_t_12 = ((float)(__pyx_v_hsl_.h * ((float)255.0))); if (((__pyx_t_11 < __pyx_t_12) != 0)) { __pyx_t_13 = __pyx_t_11; } else { __pyx_t_13 = __pyx_t_12; } __pyx_t_14 = __pyx_v_r; __pyx_t_15 = __pyx_v_g; __pyx_t_16 = __pyx_v_b; __pyx_t_17 = 0; *((float *) ( /* dim=3 */ ((char *) (((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_to_hsl.data + __pyx_t_14 * __pyx_v_rgb_to_hsl.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_to_hsl.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_to_hsl.strides[2]) )) + __pyx_t_17)) )) = __pyx_t_13;
+4191: rgb_to_hsl[r, g, b, 1] = min(<float>(hsl_.s * <float>255.0), <float>255.0)
__pyx_t_13 = ((float)255.0); __pyx_t_11 = ((float)(__pyx_v_hsl_.s * ((float)255.0))); if (((__pyx_t_13 < __pyx_t_11) != 0)) { __pyx_t_12 = __pyx_t_13; } else { __pyx_t_12 = __pyx_t_11; } __pyx_t_17 = __pyx_v_r; __pyx_t_16 = __pyx_v_g; __pyx_t_15 = __pyx_v_b; __pyx_t_14 = 1; *((float *) ( /* dim=3 */ ((char *) (((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_to_hsl.data + __pyx_t_17 * __pyx_v_rgb_to_hsl.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_to_hsl.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_to_hsl.strides[2]) )) + __pyx_t_14)) )) = __pyx_t_12;
+4192: rgb_to_hsl[r, g, b, 2] = min(<float>(hsl_.l * <float>255.0), <float>255.0)
__pyx_t_12 = ((float)255.0); __pyx_t_13 = ((float)(__pyx_v_hsl_.l * ((float)255.0))); if (((__pyx_t_12 < __pyx_t_13) != 0)) { __pyx_t_11 = __pyx_t_12; } else { __pyx_t_11 = __pyx_t_13; } __pyx_t_14 = __pyx_v_r; __pyx_t_15 = __pyx_v_g; __pyx_t_16 = __pyx_v_b; __pyx_t_17 = 2; *((float *) ( /* dim=3 */ ((char *) (((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_to_hsl.data + __pyx_t_14 * __pyx_v_rgb_to_hsl.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_to_hsl.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_to_hsl.strides[2]) )) + __pyx_t_17)) )) = __pyx_t_11; } } } } } } } #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 }
4193:
+4194: return asarray(rgb_to_hsl, dtype=float32)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_rgb_to_hsl, 4, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_float(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 4194, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; goto __pyx_L0;
4195:
4196:
4197:
4198: @cython.boundscheck(False)
4199: @cython.wraparound(False)
4200: @cython.nonecheck(False)
4201: @cython.cdivision(True)
+4202: cdef inline unsigned char [:, :, :, ::1] hsl_to_rgb_model_c():
static CYTHON_INLINE __Pyx_memviewslice __pyx_f_6shader_hsl_to_rgb_model_c(void) { __Pyx_memviewslice __pyx_v_hsl_to_rgb = { 0, 0, { 0 }, { 0 }, { 0 } }; struct rgb __pyx_v_rgb_; int __pyx_v_h; int __pyx_v_s; int __pyx_v_l; __Pyx_memviewslice __pyx_r = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hsl_to_rgb_model_c", 0); /* … */ /* 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_6); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __pyx_r.data = NULL; __pyx_r.memview = NULL; __Pyx_AddTraceback("shader.hsl_to_rgb_model_c", __pyx_clineno, __pyx_lineno, __pyx_filename); goto __pyx_L2; __pyx_L0:; if (unlikely(!__pyx_r.memview)) { PyErr_SetString(PyExc_TypeError, "Memoryview return value is not initialized"); } __pyx_L2:; __PYX_XDEC_MEMVIEW(&__pyx_v_hsl_to_rgb, 1); __Pyx_RefNannyFinishContext(); return __pyx_r; }
4203: """
4204: CONVERT HSL INTO RGB MODEL
4205:
4206: The array can be used when the hsl to rgb is extensively used
4207:
4208: All the values will be stored into an array shape (r, g, b, 3) type float
4209: :return: Numpy.ndarray shape (r, g, b, 3) type float
4210: """
+4211: cdef unsigned char [:, :, :, ::1] hsl_to_rgb = numpy.empty((256, 256, 256, 3), uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_tuple__22, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_tuple__22, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_tuple__22); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 4211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_hsl_to_rgb = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
4212: cdef rgb rgb_
4213: cdef int r, g, b
4214: cdef int h, s, l
4215:
+4216: 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:; } }
+4217: for h in prange(0, 256, schedule='static', num_threads=THREADS):
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_9 = (0x100 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_h) lastprivate(__pyx_v_h) lastprivate(__pyx_v_l) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) schedule(static) /* … */ 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_9 = (0x100 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_h) lastprivate(__pyx_v_h) lastprivate(__pyx_v_l) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_9; __pyx_t_8++){ { __pyx_v_h = (int)(0 + 1 * __pyx_t_8); /* Initialize private variables to invalid values */ __pyx_v_l = ((int)0xbad0bad0); __pyx_v_s = ((int)0xbad0bad0);
+4218: for s in range(0, 256):
/* "shader.pyx":4218 * with nogil: * for h in prange(0, 256, schedule='static', num_threads=THREADS): * for s in range(0, 256): # <<<<<<<<<<<<<< * for l in range(0, 256): * rgb_ = struct_hsl_to_rgb(h * <float>ONE_255, s * */ for (__pyx_t_5 = 0; __pyx_t_5 < 0x100; __pyx_t_5+=1) { __pyx_v_s = __pyx_t_5;
+4219: for l in range(0, 256):
for (__pyx_t_10 = 0; __pyx_t_10 < 0x100; __pyx_t_10+=1) { __pyx_v_l = __pyx_t_10;
+4220: rgb_ = struct_hsl_to_rgb(h * <float>ONE_255, s *
__pyx_v_rgb_ = struct_hsl_to_rgb((__pyx_v_h * ((float)0.00392156862745098)), (__pyx_v_s * ((float)0.00392156862745098)), (__pyx_v_l * ((float)0.00392156862745098)));
4221: <float>ONE_255, l * <float>ONE_255)
+4222: hsl_to_rgb[h, s, l, 0] =\
__pyx_t_14 = __pyx_v_h; __pyx_t_15 = __pyx_v_s; __pyx_t_16 = __pyx_v_l; __pyx_t_17 = 0; *((unsigned char *) ( /* dim=3 */ ((char *) (((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_hsl_to_rgb.data + __pyx_t_14 * __pyx_v_hsl_to_rgb.strides[0]) ) + __pyx_t_15 * __pyx_v_hsl_to_rgb.strides[1]) ) + __pyx_t_16 * __pyx_v_hsl_to_rgb.strides[2]) )) + __pyx_t_17)) )) = __pyx_t_13;
+4223: min(<unsigned char> (rgb_.r * <float>255.0), <unsigned char>255)
__pyx_t_11 = ((unsigned char)0xFF); __pyx_t_12 = ((unsigned char)(__pyx_v_rgb_.r * ((float)255.0))); if (((__pyx_t_11 < __pyx_t_12) != 0)) { __pyx_t_13 = __pyx_t_11; } else { __pyx_t_13 = __pyx_t_12; }
+4224: hsl_to_rgb[h, s, l, 1] = \
__pyx_t_17 = __pyx_v_h; __pyx_t_16 = __pyx_v_s; __pyx_t_15 = __pyx_v_l; __pyx_t_14 = 1; *((unsigned char *) ( /* dim=3 */ ((char *) (((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_hsl_to_rgb.data + __pyx_t_17 * __pyx_v_hsl_to_rgb.strides[0]) ) + __pyx_t_16 * __pyx_v_hsl_to_rgb.strides[1]) ) + __pyx_t_15 * __pyx_v_hsl_to_rgb.strides[2]) )) + __pyx_t_14)) )) = __pyx_t_12;
+4225: min(<unsigned char> (rgb_.g * <float>255.0), <unsigned char>255)
__pyx_t_13 = ((unsigned char)0xFF); __pyx_t_11 = ((unsigned char)(__pyx_v_rgb_.g * ((float)255.0))); if (((__pyx_t_13 < __pyx_t_11) != 0)) { __pyx_t_12 = __pyx_t_13; } else { __pyx_t_12 = __pyx_t_11; }
+4226: hsl_to_rgb[h, s, l, 2] = \
__pyx_t_14 = __pyx_v_h; __pyx_t_15 = __pyx_v_s; __pyx_t_16 = __pyx_v_l; __pyx_t_17 = 2; *((unsigned char *) ( /* dim=3 */ ((char *) (((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_hsl_to_rgb.data + __pyx_t_14 * __pyx_v_hsl_to_rgb.strides[0]) ) + __pyx_t_15 * __pyx_v_hsl_to_rgb.strides[1]) ) + __pyx_t_16 * __pyx_v_hsl_to_rgb.strides[2]) )) + __pyx_t_17)) )) = __pyx_t_11; } } } } } } } #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 }
+4227: min(<unsigned char> (rgb_.b * <float>255.0), <unsigned char>255)
__pyx_t_12 = ((unsigned char)0xFF); __pyx_t_13 = ((unsigned char)(__pyx_v_rgb_.b * ((float)255.0))); if (((__pyx_t_12 < __pyx_t_13) != 0)) { __pyx_t_11 = __pyx_t_12; } else { __pyx_t_11 = __pyx_t_13; }
4228:
+4229: return asarray(hsl_to_rgb, dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_hsl_to_rgb, 4, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_d_d_dc_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 4229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; goto __pyx_L0;
4230:
4231: @cython.boundscheck(False)
4232: @cython.wraparound(False)
4233: @cython.nonecheck(False)
4234: @cython.cdivision(True)
+4235: cdef inline void shader_hsl_surface24bit_inplace_c(unsigned char [:, :, :] rgb_array, float shift_):
static CYTHON_INLINE void __pyx_f_6shader_shader_hsl_surface24bit_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array, float __pyx_v_shift_) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; struct hsl __pyx_v_hsl_; struct rgb __pyx_v_rgb_; float __pyx_v_h_; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_hsl_surface24bit_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
4236:
4237: """
4238: ROTATE THE HUE OF THE GAME DISPLAY OR GIVEN TEXTURE
4239:
4240: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4241: please refer to pygame function pixels3d or array3d to convert an image into a
4242: 3d array (library surfarray)
4243:
4244: e.g:
4245: hsl(surface, 0.2)
4246:
4247: :param rgb_array : numpy.ndarray of shape(w, h, 3) of unsigned char, rgb values
4248: :param shift_ : float; Hue value in range [-1.0 ... 1.0]
4249: :return : void
4250: """
4251:
4252: cdef Py_ssize_t w, h
+4253: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
4254:
4255: cdef:
+4256: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4257: hsl hsl_
4258: rgb rgb_
4259: float h_
4260: unsigned char *r
4261: unsigned char *g
4262: unsigned char *b
4263:
4264:
+4265: 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:; } }
+4266: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_h_) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_h_) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_h_ = ((float)__PYX_NAN()); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1);
+4267: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
+4268: r = &rgb_array[i, j, 0]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+4269: g = &rgb_array[i, j, 1]
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+4270: b = &rgb_array[i, j, 2]
/* "shader.pyx":4270 * r = &rgb_array[i, j, 0] * g = &rgb_array[i, j, 1] * b = &rgb_array[i, j, 2] # <<<<<<<<<<<<<< * hsl_ = struct_rgb_to_hsl( * r[0] * <float>ONE_255, g[0] * */ __pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+4271: hsl_ = struct_rgb_to_hsl(
__pyx_v_hsl_ = struct_rgb_to_hsl(((__pyx_v_r[0]) * ((float)0.00392156862745098)), ((__pyx_v_g[0]) * ((float)0.00392156862745098)), ((__pyx_v_b[0]) * ((float)0.00392156862745098)));
4272: r[0] * <float>ONE_255, g[0] *
4273: <float>ONE_255, b[0] * <float>ONE_255)
4274:
4275: #h_ = min((hsl_.h + shift_), 1.0)
4276: #h_ = max(h_, 0.0)
+4277: h_ = hsl_.h + shift_
__pyx_v_h_ = (__pyx_v_hsl_.h + __pyx_v_shift_);
+4278: rgb_ = struct_hsl_to_rgb(h_, hsl_.s, hsl_.l)
__pyx_v_rgb_ = struct_hsl_to_rgb(__pyx_v_h_, __pyx_v_hsl_.s, __pyx_v_hsl_.l);
4279:
+4280: r[0] = <unsigned char>(rgb_.r * <float>255.0)
(__pyx_v_r[0]) = ((unsigned char)(__pyx_v_rgb_.r * ((float)255.0)));
+4281: g[0] = <unsigned char>(rgb_.g * <float>255.0)
(__pyx_v_g[0]) = ((unsigned char)(__pyx_v_rgb_.g * ((float)255.0)));
+4282: b[0] = <unsigned char>(rgb_.b * <float>255.0)
(__pyx_v_b[0]) = ((unsigned char)(__pyx_v_rgb_.b * ((float)255.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 }
4283:
4284:
4285:
4286: @cython.boundscheck(False)
4287: @cython.wraparound(False)
4288: @cython.nonecheck(False)
4289: @cython.cdivision(True)
+4290: cdef inline void shader_hsl_surface24bit_fast_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_hsl_surface24bit_fast_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array, float __pyx_v_shift_, __Pyx_memviewslice __pyx_v_hsl_model_, __Pyx_memviewslice __pyx_v_rgb_model_) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; float __pyx_v_h_; unsigned char __pyx_v_h__; unsigned char __pyx_v_s__; unsigned char __pyx_v_l__; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_hsl_surface24bit_fast_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
4291: unsigned char [:, :, :] rgb_array,
4292: float shift_,
4293: float [:, :, :, ::1] hsl_model_,
4294: unsigned char [:, :, :, ::1] rgb_model_):
4295:
4296: """
4297: ROTATE THE HUE OF AN IMAGE USING STORED HSL TO RGB AND RGB TO HSL VALUES
4298:
4299: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4300: please refer to pygame function pixels3d or array3d to convert an image into a
4301: 3d array (library surfarray)
4302:
4303: e.g:
4304: hsl(surface, 0.2, hsl_model, rgb_model)
4305:
4306: :param rgb_array : numpy.ndarray of shape(w, h, 3) of unsigned char, rgb values
4307: :param shift_ : float; Hue value in range [-1.0 ... 1.0]
4308: :param hsl_model_ : numpy.ndarray shape (r, g, b, 3) of hsl values r, g & b
4309: in range [0 ... 255]
4310: :param rgb_model_ : numpy.ndarray shape (h, s, l, 3) of hsl values h, s & l
4311: in range [0.0 ... 1.0]
4312: :return: void
4313: """
4314:
4315:
4316:
4317: cdef Py_ssize_t w, h
+4318: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
4319:
4320: cdef:
+4321: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4322:
4323: float h_
4324: unsigned char h__, s__, l__
4325:
4326: unsigned char *r
4327: unsigned char *g
4328: unsigned char *b
4329:
4330:
+4331: 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:; } }
+4332: for j in prange(h, schedule='dynamic', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_h_) lastprivate(__pyx_v_h__) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l__) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s__) schedule(dynamic) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_h_) lastprivate(__pyx_v_h__) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l__) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s__) schedule(dynamic) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_h_ = ((float)__PYX_NAN()); __pyx_v_h__ = ((unsigned char)'?'); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_l__ = ((unsigned char)'?'); __pyx_v_r = ((unsigned char *)1); __pyx_v_s__ = ((unsigned char)'?');
+4333: for i in range(w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
4334:
+4335: r = &rgb_array[i, j, 0]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+4336: g = &rgb_array[i, j, 1]
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+4337: b = &rgb_array[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
4338:
+4339: h_ = hsl_model_[r[0], g[0], b[0], 0]
__pyx_t_11 = (__pyx_v_r[0]); __pyx_t_12 = (__pyx_v_g[0]); __pyx_t_13 = (__pyx_v_b[0]); __pyx_t_10 = 0; __pyx_v_h_ = (*((float *) ( /* dim=3 */ ((char *) (((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_hsl_model_.data + __pyx_t_11 * __pyx_v_hsl_model_.strides[0]) ) + __pyx_t_12 * __pyx_v_hsl_model_.strides[1]) ) + __pyx_t_13 * __pyx_v_hsl_model_.strides[2]) )) + __pyx_t_10)) )));
4340:
+4341: h__ = <unsigned char> (<float>min((h_ * ONE_255 + shift_), <float>1.0) * \
__pyx_t_14 = ((float)1.0); __pyx_t_15 = ((__pyx_v_h_ * 0.00392156862745098) + __pyx_v_shift_); if (((__pyx_t_14 < __pyx_t_15) != 0)) { __pyx_t_16 = __pyx_t_14; } else { __pyx_t_16 = __pyx_t_15; } /* … */ __pyx_v_h__ = ((unsigned char)(((float)__pyx_t_16) * ((float)255.0)));
4342: <float>255.0)
4343:
+4344: s__ = <unsigned char> hsl_model_[r[0], g[0], b[0], 1]
__pyx_t_13 = (__pyx_v_r[0]); __pyx_t_12 = (__pyx_v_g[0]); __pyx_t_11 = (__pyx_v_b[0]); __pyx_t_10 = 1; __pyx_v_s__ = ((unsigned char)(*((float *) ( /* dim=3 */ ((char *) (((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_hsl_model_.data + __pyx_t_13 * __pyx_v_hsl_model_.strides[0]) ) + __pyx_t_12 * __pyx_v_hsl_model_.strides[1]) ) + __pyx_t_11 * __pyx_v_hsl_model_.strides[2]) )) + __pyx_t_10)) ))));
+4345: l__ = <unsigned char> hsl_model_[r[0], g[0], b[0], 2]
__pyx_t_11 = (__pyx_v_r[0]); __pyx_t_12 = (__pyx_v_g[0]); __pyx_t_13 = (__pyx_v_b[0]); __pyx_t_10 = 2; __pyx_v_l__ = ((unsigned char)(*((float *) ( /* dim=3 */ ((char *) (((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_hsl_model_.data + __pyx_t_11 * __pyx_v_hsl_model_.strides[0]) ) + __pyx_t_12 * __pyx_v_hsl_model_.strides[1]) ) + __pyx_t_13 * __pyx_v_hsl_model_.strides[2]) )) + __pyx_t_10)) ))));
4346:
+4347: r[0] = (&rgb_model_[h__, s__, l__, 0])[0]
__pyx_t_13 = __pyx_v_h__; __pyx_t_12 = __pyx_v_s__; __pyx_t_11 = __pyx_v_l__; __pyx_t_10 = 0; (__pyx_v_r[0]) = ((&(*((unsigned char *) ( /* dim=3 */ ((char *) (((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_model_.data + __pyx_t_13 * __pyx_v_rgb_model_.strides[0]) ) + __pyx_t_12 * __pyx_v_rgb_model_.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_model_.strides[2]) )) + __pyx_t_10)) ))))[0]);
+4348: g[0] = (&rgb_model_[h__, s__, l__, 1])[0]
__pyx_t_11 = __pyx_v_h__; __pyx_t_12 = __pyx_v_s__; __pyx_t_13 = __pyx_v_l__; __pyx_t_10 = 1; (__pyx_v_g[0]) = ((&(*((unsigned char *) ( /* dim=3 */ ((char *) (((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_model_.data + __pyx_t_11 * __pyx_v_rgb_model_.strides[0]) ) + __pyx_t_12 * __pyx_v_rgb_model_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_model_.strides[2]) )) + __pyx_t_10)) ))))[0]);
+4349: b[0] = (&rgb_model_[h__, s__, l__, 2])[0]
__pyx_t_13 = __pyx_v_h__; __pyx_t_12 = __pyx_v_s__; __pyx_t_11 = __pyx_v_l__; __pyx_t_10 = 2; (__pyx_v_b[0]) = ((&(*((unsigned char *) ( /* dim=3 */ ((char *) (((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_model_.data + __pyx_t_13 * __pyx_v_rgb_model_.strides[0]) ) + __pyx_t_12 * __pyx_v_rgb_model_.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_model_.strides[2]) )) + __pyx_t_10)) ))))[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 }
4350:
4351:
4352:
4353: @cython.boundscheck(False)
4354: @cython.wraparound(False)
4355: @cython.nonecheck(False)
4356: @cython.cdivision(True)
+4357: cdef inline void shader_brightness24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_brightness24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_brightness24_inplace_c *__pyx_optional_args) { float __pyx_v_shift_ = ((float)0.0); Py_ssize_t __pyx_v_width; CYTHON_UNUSED Py_ssize_t __pyx_v_height; int __pyx_v_i; int __pyx_v_j; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; float __pyx_v_l; struct hsl __pyx_v_hsl_; struct rgb __pyx_v_rgb_; CYTHON_UNUSED int __pyx_v_exclude_color; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_brightness24_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_shift_ = __pyx_optional_args->shift_; } } /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_brightness24_inplace_c { int __pyx_n; float shift_; };
4358: unsigned char [:, :, :] rgb_array_, float shift_=0):
4359: """
4360: SHADER BRIGHTNESS
4361:
4362: This shader control the pygame display brightness level
4363: It uses two external functions coded in C, struct_rgb_to_hsl & struct_hsl_to_rgb
4364:
4365: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4366: please refer to pygame function pixels3d or array3d to convert an image into
4367: a 3d array (library surfarray)
4368:
4369: e.g:
4370: brightness(surface, 0.2)
4371:
4372: :param rgb_array_: numpy ndarray shape (w, h, 3) containing RGB pixels values
4373: :param shift_ : float; values in range [-1.0 ... 1.0], 0 no change,
4374: -1 lowest brightness, +1 highest brightness
4375: :return : void
4376: """
4377:
4378: cdef Py_ssize_t width, height
+4379: width, height = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_width = __pyx_t_2; __pyx_v_height = __pyx_t_3;
4380:
4381: cdef:
+4382: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4383: unsigned char *r
4384: unsigned char *g
4385: unsigned char *b
4386: float l, h, s
4387: hsl hsl_
4388: rgb rgb_
4389: float high, low, high_
4390: unsigned char exclude_r, exclude_g, exclude_b
+4391: bint exclude_color = False
__pyx_v_exclude_color = 0;
4392:
+4393: 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:; } }
+4394: for j in prange(height, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_height; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static) /* … */ __pyx_t_3 = __pyx_v_height; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_l = ((float)__PYX_NAN()); __pyx_v_r = ((unsigned char *)1);
+4395: for i in range(width):
__pyx_t_5 = __pyx_v_width; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
4396:
+4397: r, g, b = &rgb_array_[i, j, 0], &rgb_array_[i, j, 1], &rgb_array_[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_t_11 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_8 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_t_12 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; __pyx_t_14 = 1; __pyx_t_15 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 2; __pyx_t_19 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_v_r = __pyx_t_11; __pyx_v_g = __pyx_t_15; __pyx_v_b = __pyx_t_19;
4398:
+4399: hsl_ = struct_rgb_to_hsl(
__pyx_v_hsl_ = struct_rgb_to_hsl(((__pyx_v_r[0]) * ((float)0.00392156862745098)), ((__pyx_v_g[0]) * ((float)0.00392156862745098)), ((__pyx_v_b[0]) * ((float)0.00392156862745098)));
4400: r[0] * <float>ONE_255, g[0] *
4401: <float>ONE_255, b[0] * <float>ONE_255)
4402:
+4403: l = min((hsl_.l + shift_), <float>1.0)
__pyx_t_20 = ((float)1.0); __pyx_t_21 = (__pyx_v_hsl_.l + __pyx_v_shift_); if (((__pyx_t_20 < __pyx_t_21) != 0)) { __pyx_t_22 = __pyx_t_20; } else { __pyx_t_22 = __pyx_t_21; } __pyx_v_l = __pyx_t_22;
+4404: l = max(l, <float>0.0)
__pyx_t_22 = ((float)0.0); __pyx_t_20 = __pyx_v_l; if (((__pyx_t_22 > __pyx_t_20) != 0)) { __pyx_t_21 = __pyx_t_22; } else { __pyx_t_21 = __pyx_t_20; } __pyx_v_l = __pyx_t_21;
4405:
+4406: rgb_ = struct_hsl_to_rgb(hsl_.h, hsl_.s, l)
__pyx_v_rgb_ = struct_hsl_to_rgb(__pyx_v_hsl_.h, __pyx_v_hsl_.s, __pyx_v_l);
4407:
+4408: r[0] = <unsigned char> (rgb_.r * 255.0)
(__pyx_v_r[0]) = ((unsigned char)(__pyx_v_rgb_.r * 255.0));
+4409: g[0] = <unsigned char> (rgb_.g * 255.0)
(__pyx_v_g[0]) = ((unsigned char)(__pyx_v_rgb_.g * 255.0));
+4410: b[0] = <unsigned char> (rgb_.b * 255.0)
(__pyx_v_b[0]) = ((unsigned char)(__pyx_v_rgb_.b * 255.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 }
4411:
4412:
4413:
4414: @cython.boundscheck(False)
4415: @cython.wraparound(False)
4416: @cython.nonecheck(False)
4417: @cython.cdivision(True)
+4418: cdef inline void shader_brightness24_exclude_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_brightness24_exclude_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_brightness24_exclude_inplace_c *__pyx_optional_args) { float __pyx_v_shift_ = ((float)0.0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_WriteUnraisable("shader.shader_brightness24_exclude_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_brightness24_exclude_inplace_c { int __pyx_n; float shift_; PyObject *color_; };
+4419: unsigned char [:, :, :] rgb_array_, float shift_=0.0, color_=(0, 0, 0)):
PyObject *__pyx_v_color_ = ((PyObject *)__pyx_tuple__9); Py_ssize_t __pyx_v_width; Py_ssize_t __pyx_v_height; int __pyx_v_i; int __pyx_v_j; unsigned char __pyx_v_r; unsigned char __pyx_v_g; unsigned char __pyx_v_b; float __pyx_v_l; struct hsl __pyx_v_hsl_; struct rgb __pyx_v_rgb_; unsigned char __pyx_v_rr; unsigned char __pyx_v_gg; unsigned char __pyx_v_bb; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_brightness24_exclude_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_shift_ = __pyx_optional_args->shift_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_color_ = __pyx_optional_args->color_; } } }
4420: """
4421: SHADER BRIGHTNESS (EXCLUDE A SPECIFIC COLOR FROM THE PROCESS, DEFAULT BLACK COLOR)
4422:
4423: This shader control the pygame display brightness level
4424: It uses two external functions coded in C, struct_rgb_to_hsl & struct_hsl_to_rgb
4425:
4426: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4427: please refer to pygame function pixels3d or array3d to convert an image into a
4428: 3d array (library surfarray)
4429:
4430: e.g:
4431: brightness_exclude(surface, 0.2)
4432:
4433: :param rgb_array_: numpy ndarray shape (w, h, 3) containing RGB pixels values
4434: :param shift_ : float; values in range [-1.0 ... 1.0], 0 no change,
4435: -1 lowest brightness, +1 highest brightness
4436: :param color_ : tuple; Color to exclude from the brightness process
4437: :return : void
4438: """
4439:
4440: cdef Py_ssize_t width, height
+4441: width, height = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_width = __pyx_t_2; __pyx_v_height = __pyx_t_3;
4442:
4443: cdef:
+4444: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4445: unsigned char r
4446: unsigned char g
4447: unsigned char b
4448: float l, h, s
4449: hsl hsl_
4450: rgb rgb_
4451: float high, low, high_
+4452: unsigned char rr=color_[0], gg=color_[1], bb=color_[2]
__pyx_t_4 = __Pyx_GetItemInt(__pyx_v_color_, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_As_unsigned_char(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 4452, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rr = __pyx_t_5; __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_color_, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_As_unsigned_char(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 4452, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_gg = __pyx_t_5; __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_color_, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_As_unsigned_char(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 4452, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_bb = __pyx_t_5;
4453:
+4454: 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:; } }
+4455: for j in range(height): #, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_height; __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;
+4456: for i in range(width):
__pyx_t_7 = __pyx_v_width; __pyx_t_8 = __pyx_t_7; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_i = __pyx_t_9;
4457:
+4458: r, g, b = rgb_array_[i, j, 0], rgb_array_[i, j, 1], rgb_array_[i, j, 2]
__pyx_t_10 = __pyx_v_i; __pyx_t_11 = __pyx_v_j; __pyx_t_12 = 0; __pyx_t_5 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_12 = __pyx_v_i; __pyx_t_11 = __pyx_v_j; __pyx_t_10 = 1; __pyx_t_13 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_10 = __pyx_v_i; __pyx_t_11 = __pyx_v_j; __pyx_t_12 = 2; __pyx_t_14 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_r = __pyx_t_5; __pyx_v_g = __pyx_t_13; __pyx_v_b = __pyx_t_14;
4459:
+4460: if not ((r==rr) and (g==gg) and (b==bb)):
__pyx_t_16 = ((__pyx_v_r == __pyx_v_rr) != 0); if (__pyx_t_16) { } else { __pyx_t_15 = __pyx_t_16; goto __pyx_L11_bool_binop_done; } __pyx_t_16 = ((__pyx_v_g == __pyx_v_gg) != 0); if (__pyx_t_16) { } else { __pyx_t_15 = __pyx_t_16; goto __pyx_L11_bool_binop_done; } __pyx_t_16 = ((__pyx_v_b == __pyx_v_bb) != 0); __pyx_t_15 = __pyx_t_16; __pyx_L11_bool_binop_done:; __pyx_t_16 = ((!__pyx_t_15) != 0); if (__pyx_t_16) { /* … */ } } } }
4461:
+4462: hsl_ = struct_rgb_to_hsl(
__pyx_v_hsl_ = struct_rgb_to_hsl((__pyx_v_r * ((float)0.00392156862745098)), (__pyx_v_g * ((float)0.00392156862745098)), (__pyx_v_b * ((float)0.00392156862745098)));
4463: r * <float>ONE_255, g * <float>ONE_255, b * <float>ONE_255)
4464:
+4465: l = min((hsl_.l + shift_), <float>1.0)
__pyx_t_17 = ((float)1.0); __pyx_t_18 = (__pyx_v_hsl_.l + __pyx_v_shift_); if (((__pyx_t_17 < __pyx_t_18) != 0)) { __pyx_t_19 = __pyx_t_17; } else { __pyx_t_19 = __pyx_t_18; } __pyx_v_l = __pyx_t_19;
+4466: l = max(l, <float>0.0)
__pyx_t_19 = ((float)0.0); __pyx_t_17 = __pyx_v_l; if (((__pyx_t_19 > __pyx_t_17) != 0)) { __pyx_t_18 = __pyx_t_19; } else { __pyx_t_18 = __pyx_t_17; } __pyx_v_l = __pyx_t_18;
4467:
+4468: rgb_ = struct_hsl_to_rgb(hsl_.h, hsl_.s, l)
__pyx_v_rgb_ = struct_hsl_to_rgb(__pyx_v_hsl_.h, __pyx_v_hsl_.s, __pyx_v_l);
4469:
+4470: rgb_array_[i, j, 0] = <unsigned char> (rgb_.r * 255.0)
__pyx_t_12 = __pyx_v_i; __pyx_t_11 = __pyx_v_j; __pyx_t_10 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)(__pyx_v_rgb_.r * 255.0));
+4471: rgb_array_[i, j, 1] = <unsigned char> (rgb_.g * 255.0)
__pyx_t_10 = __pyx_v_i; __pyx_t_11 = __pyx_v_j; __pyx_t_12 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)(__pyx_v_rgb_.g * 255.0));
+4472: rgb_array_[i, j, 2] = <unsigned char> (rgb_.b * 255.0)
__pyx_t_12 = __pyx_v_i; __pyx_t_11 = __pyx_v_j; __pyx_t_10 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)(__pyx_v_rgb_.b * 255.0));
4473:
4474:
4475:
4476: @cython.boundscheck(False)
4477: @cython.wraparound(False)
4478: @cython.nonecheck(False)
4479: @cython.cdivision(True)
+4480: cdef inline void shader_brightness24_bpf_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_brightness24_bpf_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_brightness24_bpf_c *__pyx_optional_args) { float __pyx_v_shift_ = ((float)0.0); unsigned char __pyx_v_bpf_treshold_ = ((unsigned char)64); Py_ssize_t __pyx_v_width; CYTHON_UNUSED Py_ssize_t __pyx_v_height; int __pyx_v_i; int __pyx_v_j; unsigned char __pyx_v_r; unsigned char __pyx_v_g; unsigned char __pyx_v_b; float __pyx_v_l; struct hsl __pyx_v_hsl_; struct rgb __pyx_v_rgb_; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_brightness24_bpf_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_shift_ = __pyx_optional_args->shift_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_bpf_treshold_ = __pyx_optional_args->bpf_treshold_; } } } /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_brightness24_bpf_c { int __pyx_n; float shift_; unsigned char bpf_treshold_; };
4481: unsigned char [:, :, :] rgb_array_,
4482: float shift_=0.0,
4483: unsigned char bpf_treshold_=64):
4484: """
4485:
4486: :param rgb_array_: numpy ndarray shape (w, h, 3) containing RGB pixels values
4487: :param shift_ : float; values in range [-1.0 ... 1.0], 0 no change,
4488: -1 lowest brightness, +1 highest brightness
4489: :param bpf_treshold_ : integer; Bright pass filter threshold value
4490: :return : void
4491: """
4492:
4493:
4494: cdef Py_ssize_t width, height
+4495: width, height = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_width = __pyx_t_2; __pyx_v_height = __pyx_t_3;
4496:
4497: cdef:
+4498: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4499: unsigned char r
4500: unsigned char g
4501: unsigned char b
4502: float l, h, s
4503: hsl hsl_
4504: rgb rgb_
4505: float high, low, high_
4506:
4507:
+4508: 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:; } }
+4509: for j in prange(height, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_height; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static) /* … */ __pyx_t_3 = __pyx_v_height; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char)'?'); __pyx_v_g = ((unsigned char)'?'); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_l = ((float)__PYX_NAN()); __pyx_v_r = ((unsigned char)'?');
+4510: for i in range(width):
__pyx_t_5 = __pyx_v_width; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_i = __pyx_t_7;
4511:
+4512: r, g, b = rgb_array_[i, j, 0], rgb_array_[i, j, 1], rgb_array_[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_t_11 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_8 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 1; __pyx_t_12 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 2; __pyx_t_13 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_8 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_r = __pyx_t_11; __pyx_v_g = __pyx_t_12; __pyx_v_b = __pyx_t_13;
4513:
+4514: if r + g + b < bpf_treshold_:
__pyx_t_14 = ((((__pyx_v_r + __pyx_v_g) + __pyx_v_b) < __pyx_v_bpf_treshold_) != 0); if (__pyx_t_14) { /* … */ }
+4515: continue
goto __pyx_L10_continue;
4516:
+4517: hsl_ = struct_rgb_to_hsl(
__pyx_v_hsl_ = struct_rgb_to_hsl((__pyx_v_r * ((float)0.00392156862745098)), (__pyx_v_g * ((float)0.00392156862745098)), (__pyx_v_b * ((float)0.00392156862745098)));
4518: r * <float>ONE_255, g * <float>ONE_255, b * <float>ONE_255)
4519:
+4520: l = min((hsl_.l + shift_), <float>1.0)
__pyx_t_15 = ((float)1.0); __pyx_t_16 = (__pyx_v_hsl_.l + __pyx_v_shift_); if (((__pyx_t_15 < __pyx_t_16) != 0)) { __pyx_t_17 = __pyx_t_15; } else { __pyx_t_17 = __pyx_t_16; } __pyx_v_l = __pyx_t_17;
+4521: l = max(l, <float>0.0)
__pyx_t_17 = ((float)0.0); __pyx_t_15 = __pyx_v_l; if (((__pyx_t_17 > __pyx_t_15) != 0)) { __pyx_t_16 = __pyx_t_17; } else { __pyx_t_16 = __pyx_t_15; } __pyx_v_l = __pyx_t_16;
4522:
+4523: rgb_ = struct_hsl_to_rgb(hsl_.h, hsl_.s, l)
__pyx_v_rgb_ = struct_hsl_to_rgb(__pyx_v_hsl_.h, __pyx_v_hsl_.s, __pyx_v_l);
4524:
+4525: rgb_array_[i, j, 0] = <unsigned char> (rgb_.r * 255.0 )
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)(__pyx_v_rgb_.r * 255.0));
+4526: rgb_array_[i, j, 1] = <unsigned char> (rgb_.g * 255.0 )
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_8 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)(__pyx_v_rgb_.g * 255.0));
+4527: rgb_array_[i, j, 2] = <unsigned char> (rgb_.b * 255.0 )
__pyx_t_10 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_8 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)(__pyx_v_rgb_.b * 255.0)); __pyx_L10_continue:; } } } } } } #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 }
4528:
4529:
4530:
4531: @cython.boundscheck(False)
4532: @cython.wraparound(False)
4533: @cython.nonecheck(False)
4534: @cython.cdivision(True)
+4535: cdef inline void shader_brightness_24_inplace1_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_brightness_24_inplace1_c(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_shift_, __Pyx_memviewslice __pyx_v_rgb_to_hsl_model) { CYTHON_UNUSED Py_ssize_t __pyx_v_width; Py_ssize_t __pyx_v_height; int __pyx_v_i; int __pyx_v_j; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; float __pyx_v_l; float __pyx_v_h; float __pyx_v_s; struct rgb __pyx_v_rgb_; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_brightness_24_inplace1_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
4536: unsigned char [:, :, :] rgb_array_, float shift_, float [:, :, :, :] rgb_to_hsl_model):
4537: """
4538: SHADER BRIGHTNESS USING STORED RGB TO HSL VALUES (SLOWEST VERSION)
4539:
4540: This method is fetching all the HSL values from an array instead
4541: In theory this method should be faster than the direct calculation therefore the size of the
4542: array degrade the performance somehow.
4543:
4544: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4545: please refer to pygame function pixels3d or array3d to convert an image into a
4546: 3d array (library surfarray)
4547:
4548: e.g:
4549: brightness_model(surface, 0.2 rgb_to_hsl_model)
4550:
4551: :param rgb_array_ : numpy.ndarray containing RGB values array shapes (w, h, 3) uint8
4552: :param shift_ : float; value in range[-1.0 ... 1.0]
4553: :param rgb_to_hsl_model: Array shape (r, g, b, 3) containing all pre-calculated HSL values
4554: :return : void
4555: """
4556:
4557: cdef Py_ssize_t width, height
+4558: width, height = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_width = __pyx_t_2; __pyx_v_height = __pyx_t_3;
4559:
4560: cdef:
+4561: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4562: unsigned char *r
4563: unsigned char *g
4564: unsigned char *b
4565: float l, h, s
4566:
4567: rgb rgb_
4568: float high, low, high_
4569:
+4570: 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:; } }
4571:
+4572: for i in prange(width, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_h) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) schedule(static) /* … */ __pyx_t_3 = __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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_h) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_l) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_h = ((float)__PYX_NAN()); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_l = ((float)__PYX_NAN()); __pyx_v_r = ((unsigned char *)1); __pyx_v_s = ((float)__PYX_NAN());
+4573: for j in range(height):
__pyx_t_5 = __pyx_v_height; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_j = __pyx_t_7;
4574:
+4575: r, g, b = &rgb_array_[i, j, 0], &rgb_array_[i, j, 1], &rgb_array_[i, j, 2]
__pyx_t_8 = __pyx_v_i; __pyx_t_9 = __pyx_v_j; __pyx_t_10 = 0; __pyx_t_11 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_8 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_t_12 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; __pyx_t_14 = 1; __pyx_t_15 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 2; __pyx_t_19 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_v_r = __pyx_t_11; __pyx_v_g = __pyx_t_15; __pyx_v_b = __pyx_t_19;
4576:
+4577: h = rgb_to_hsl_model[r[0], g[0], b[0], 0]
__pyx_t_20 = (__pyx_v_r[0]); __pyx_t_21 = (__pyx_v_g[0]); __pyx_t_22 = (__pyx_v_b[0]); __pyx_t_18 = 0; __pyx_v_h = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_to_hsl_model.data + __pyx_t_20 * __pyx_v_rgb_to_hsl_model.strides[0]) ) + __pyx_t_21 * __pyx_v_rgb_to_hsl_model.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_to_hsl_model.strides[2]) ) + __pyx_t_18 * __pyx_v_rgb_to_hsl_model.strides[3]) )));
+4578: s = rgb_to_hsl_model[r[0], g[0], b[0], 1]
__pyx_t_22 = (__pyx_v_r[0]); __pyx_t_21 = (__pyx_v_g[0]); __pyx_t_20 = (__pyx_v_b[0]); __pyx_t_18 = 1; __pyx_v_s = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_to_hsl_model.data + __pyx_t_22 * __pyx_v_rgb_to_hsl_model.strides[0]) ) + __pyx_t_21 * __pyx_v_rgb_to_hsl_model.strides[1]) ) + __pyx_t_20 * __pyx_v_rgb_to_hsl_model.strides[2]) ) + __pyx_t_18 * __pyx_v_rgb_to_hsl_model.strides[3]) )));
+4579: l = rgb_to_hsl_model[r[0], g[0], b[0], 2]
__pyx_t_20 = (__pyx_v_r[0]); __pyx_t_21 = (__pyx_v_g[0]); __pyx_t_22 = (__pyx_v_b[0]); __pyx_t_18 = 2; __pyx_v_l = (*((float *) ( /* dim=3 */ (( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_to_hsl_model.data + __pyx_t_20 * __pyx_v_rgb_to_hsl_model.strides[0]) ) + __pyx_t_21 * __pyx_v_rgb_to_hsl_model.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_to_hsl_model.strides[2]) ) + __pyx_t_18 * __pyx_v_rgb_to_hsl_model.strides[3]) )));
4580:
+4581: l = min((l + shift_), <float>1.0)
__pyx_t_23 = ((float)1.0); __pyx_t_24 = (__pyx_v_l + __pyx_v_shift_); if (((__pyx_t_23 < __pyx_t_24) != 0)) { __pyx_t_25 = __pyx_t_23; } else { __pyx_t_25 = __pyx_t_24; } __pyx_v_l = __pyx_t_25;
+4582: l = max(l, <float>0.0)
__pyx_t_25 = ((float)0.0); __pyx_t_23 = __pyx_v_l; if (((__pyx_t_25 > __pyx_t_23) != 0)) { __pyx_t_24 = __pyx_t_25; } else { __pyx_t_24 = __pyx_t_23; } __pyx_v_l = __pyx_t_24;
4583:
+4584: rgb_ = struct_hsl_to_rgb(h, s, l)
__pyx_v_rgb_ = struct_hsl_to_rgb(__pyx_v_h, __pyx_v_s, __pyx_v_l);
+4585: r[0] = <unsigned char> (rgb_.r * <float>255.0)
(__pyx_v_r[0]) = ((unsigned char)(__pyx_v_rgb_.r * ((float)255.0)));
+4586: g[0] = <unsigned char> (rgb_.g * <float>255.0)
(__pyx_v_g[0]) = ((unsigned char)(__pyx_v_rgb_.g * ((float)255.0)));
+4587: b[0] = <unsigned char> (rgb_.b * <float>255.0)
(__pyx_v_b[0]) = ((unsigned char)(__pyx_v_rgb_.b * ((float)255.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 }
4588:
4589:
4590:
4591:
4592: @cython.boundscheck(False)
4593: @cython.wraparound(False)
4594: @cython.nonecheck(False)
4595: @cython.cdivision(True)
+4596: cdef inline void shader_saturation_array24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_saturation_array24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_shift_) { Py_ssize_t __pyx_v_width; CYTHON_UNUSED Py_ssize_t __pyx_v_height; int __pyx_v_i; int __pyx_v_j; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; float __pyx_v_s; struct hsl __pyx_v_hsl_; struct rgb __pyx_v_rgb_; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_saturation_array24_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_WriteUnraisable("shader.shader_saturation_array24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
4597: unsigned char [:, :, :] rgb_array_, float shift_):
4598: """
4599: SHADER SATURATION
4600:
4601: This shader control the saturation level of the pygame display or surface/texture
4602:
4603: The Array (rgb_array) must be a numpy array shape (w, h, 3)
4604: containing RGB pixels, please refer to pygame
4605: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
4606:
4607: e.g:
4608: saturation(surface, 0.2)
4609:
4610: :param rgb_array_: numpy.ndarray shape (w, h, 3) containing RGB values uint8
4611: :param shift_ : float; value in range[-1.0...1.0], control the saturation level
4612: :return : void
4613: """
4614:
+4615: assert -1.0 <= shift_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (-1.0 <= __pyx_v_shift_); if (__pyx_t_1) { __pyx_t_1 = (__pyx_v_shift_ <= 1.0); } if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_shift_must_be_in_range); __PYX_ERR(1, 4615, __pyx_L1_error) } } #endif
4616: "Argument shift must be in range[-1.0 ... 1.0]"
4617:
4618: cdef Py_ssize_t width, height
+4619: width, height = rgb_array_.shape[:2]
__pyx_t_2 = __pyx_v_rgb_array_.shape; __pyx_t_3 = (__pyx_t_2[0]); __pyx_t_4 = (__pyx_t_2[1]); __pyx_v_width = __pyx_t_3; __pyx_v_height = __pyx_t_4;
4620:
4621: cdef:
+4622: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
4623: unsigned char *r
4624: unsigned char *g
4625: unsigned char *b
4626: float s
4627: hsl hsl_
4628: rgb rgb_
4629:
4630:
+4631: 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:; } }
+4632: for j in prange(height, schedule='static', num_threads=THREADS):
__pyx_t_4 = __pyx_v_height; 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_5 = (__pyx_t_4 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) schedule(static) /* … */ __pyx_t_4 = __pyx_v_height; 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_5 = (__pyx_t_4 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_hsl_) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_3); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_s = ((float)__PYX_NAN());
+4633: for i in range(width):
__pyx_t_6 = __pyx_v_width; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
+4634: r, g, b = &rgb_array_[i, j, 0], &rgb_array_[i, j, 1], &rgb_array_[i, j, 2]
__pyx_t_9 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_11 = 0; __pyx_t_12 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_9 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_t_13 = __pyx_v_i; __pyx_t_14 = __pyx_v_j; __pyx_t_15 = 1; __pyx_t_16 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_t_17 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_19 = 2; __pyx_t_20 = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_17 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_19 * __pyx_v_rgb_array_.strides[2]) )))); __pyx_v_r = __pyx_t_12; __pyx_v_g = __pyx_t_16; __pyx_v_b = __pyx_t_20;
+4635: hsl_ = struct_rgb_to_hsl(<float>r[0] * <float>ONE_255,
__pyx_v_hsl_ = struct_rgb_to_hsl((((float)(__pyx_v_r[0])) * ((float)0.00392156862745098)), (((float)(__pyx_v_g[0])) * ((float)0.00392156862745098)), (((float)(__pyx_v_b[0])) * ((float)0.00392156862745098)));
4636: <float>g[0] * <float>ONE_255,
4637: <float>b[0] * <float>ONE_255)
4638:
+4639: s = min((hsl_.s + shift_), <float>0.5)
__pyx_t_21 = ((float)0.5); __pyx_t_22 = (__pyx_v_hsl_.s + __pyx_v_shift_); if (((__pyx_t_21 < __pyx_t_22) != 0)) { __pyx_t_23 = __pyx_t_21; } else { __pyx_t_23 = __pyx_t_22; } __pyx_v_s = __pyx_t_23;
+4640: s = max(s, <float>0.0)
__pyx_t_23 = ((float)0.0); __pyx_t_21 = __pyx_v_s; if (((__pyx_t_23 > __pyx_t_21) != 0)) { __pyx_t_22 = __pyx_t_23; } else { __pyx_t_22 = __pyx_t_21; } __pyx_v_s = __pyx_t_22;
+4641: rgb_ = struct_hsl_to_rgb(hsl_.h, s, hsl_.l)
__pyx_v_rgb_ = struct_hsl_to_rgb(__pyx_v_hsl_.h, __pyx_v_s, __pyx_v_hsl_.l);
+4642: r[0] = <unsigned char>(rgb_.r * <float>255.0)
(__pyx_v_r[0]) = ((unsigned char)(__pyx_v_rgb_.r * ((float)255.0)));
+4643: g[0] = <unsigned char>(rgb_.g * <float>255.0)
(__pyx_v_g[0]) = ((unsigned char)(__pyx_v_rgb_.g * ((float)255.0)));
+4644: b[0] = <unsigned char>(rgb_.b * <float>255.0)
(__pyx_v_b[0]) = ((unsigned char)(__pyx_v_rgb_.b * ((float)255.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 }
4645:
4646:
4647:
4648:
4649:
4650: @cython.boundscheck(False)
4651: @cython.wraparound(False)
4652: @cython.nonecheck(False)
4653: @cython.cdivision(True)
4654: # e.g
4655: # heatwave_vertical(
4656: # surface_, numpy.full((w, h), 255, dtype=numpy.uint8),
4657: # b*random.uniform(55.0, 100), 0, sigma_=random.uniform(0.4, 1), mu_=b*2)
+4658: cdef inline void shader_heatwave24_vertical_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_heatwave24_vertical_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, CYTHON_UNUSED __Pyx_memviewslice __pyx_v_mask, float __pyx_v_amplitude_, float __pyx_v_center_, float __pyx_v_sigma_, float __pyx_v_mu_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_yy; int __pyx_v_h_1; __Pyx_memviewslice __pyx_v_f_gauss = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_heatwave24_vertical_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __Pyx_WriteUnraisable("shader.shader_heatwave24_vertical_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_f_gauss, 1); __Pyx_RefNannyFinishContext(); }
4659: unsigned char [:, :, :] rgb_array_,
4660: unsigned char [:, :] mask,
4661: float amplitude_,
4662: float center_,
4663: float sigma_,
4664: float mu_):
4665: """
4666: APPLY A GAUSSIAN TRANSFORMATION TO AN ARRAY
4667:
4668: This effect can be use for simulate air turbulence or heat flow/convection
4669:
4670: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels, please refer to pygame
4671: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
4672:
4673:
4674: :param rgb_array_: numpy.ndarray shape (width, height, 3) uint8 containing RGB pixels
4675: :param mask : numpy.ndarray shape (x, y) uint8, (values 255 or 0).
4676: Apply transformation to the original array
4677: if the value @(x, y) is 255 else remain unchanged.
4678: :param amplitude_: Control the maximum of the gaussian equation.
4679: No transformation if factor_ equal zero
4680: :param center_ : Control the center of the gaussian equation (if center_ equal zero,
4681: the Gauss equation is centered
4682: at x=0 and maximum is 0.4 with amplitude_ = 1.0)
4683: :param sigma_ : float; sigma value of the gauss equation
4684: :param mu_ : float; mu value of the gauss equation
4685: :return : void
4686: """
4687: # TODO MASK
4688:
4689: cdef Py_ssize_t w, h
+4690: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
4691:
4692: cdef:
+4693: unsigned char [:, :, :] rgb_array_copy = numpy.array(rgb_array_, copy=False)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(1, 4693, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 4693, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb_array_copy = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+4694: int x = 0, y = 0
__pyx_v_x = 0; __pyx_v_y = 0;
4695: int yy
+4696: int h_1 = <int>h - 1
__pyx_v_h_1 = (((int)__pyx_v_h) - 1);
4697: unsigned char *r
+4698: float [::1] f_gauss = linspace(-4, 4, w, dtype=float32)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_linspace); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_int_neg_4); __Pyx_GIVEREF(__pyx_int_neg_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_neg_4); __Pyx_INCREF(__pyx_int_4); __Pyx_GIVEREF(__pyx_int_4); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_float(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 4698, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_f_gauss = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
4699:
4700:
+4701: 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:; } }
4702:
+4703: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_10 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_3 = __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_10 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_10; __pyx_t_2++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
4704:
+4705: for y in range(h):
__pyx_t_11 = __pyx_v_h; __pyx_t_12 = __pyx_t_11; for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_y = __pyx_t_13;
4706:
+4707: yy =<int>(gauss(f_gauss[x], center_, sigma_, mu_) * amplitude_ + y)
__pyx_t_14 = __pyx_v_x; __pyx_t_16.__pyx_n = 2; __pyx_t_16.sigma = __pyx_v_sigma_; __pyx_t_16.mu = __pyx_v_mu_; __pyx_t_15 = __pyx_f_6shader_gauss((*((float *) ( /* dim=0 */ ((char *) (((float *) __pyx_v_f_gauss.data) + __pyx_t_14)) ))), __pyx_v_center_, &__pyx_t_16); __pyx_v_yy = ((int)((__pyx_t_15 * __pyx_v_amplitude_) + __pyx_v_y));
4708:
4709: # printf("\n %i ", yy)
+4710: if yy > h_1:
__pyx_t_17 = ((__pyx_v_yy > __pyx_v_h_1) != 0); if (__pyx_t_17) { /* … */ }
+4711: yy = h_1
__pyx_v_yy = __pyx_v_h_1;
4712:
+4713: if yy < 0:
__pyx_t_17 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_17) { /* … */ }
+4714: yy = 0
__pyx_v_yy = 0;
4715:
+4716: rgb_array_[x, y, 0] = rgb_array_copy[x, yy, 0]
__pyx_t_14 = __pyx_v_x; __pyx_t_18 = __pyx_v_yy; __pyx_t_19 = 0; __pyx_t_20 = __pyx_v_x; __pyx_t_21 = __pyx_v_y; __pyx_t_22 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_20 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_21 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_18 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_19 * __pyx_v_rgb_array_copy.strides[2]) )));
+4717: rgb_array_[x, y, 1] = rgb_array_copy[x, yy, 1]
__pyx_t_19 = __pyx_v_x; __pyx_t_18 = __pyx_v_yy; __pyx_t_14 = 1; __pyx_t_22 = __pyx_v_x; __pyx_t_21 = __pyx_v_y; __pyx_t_20 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_22 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_21 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_20 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_19 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_18 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[2]) )));
+4718: rgb_array_[x, y, 2] = rgb_array_copy[x, yy, 2]
__pyx_t_14 = __pyx_v_x; __pyx_t_18 = __pyx_v_yy; __pyx_t_19 = 2; __pyx_t_20 = __pyx_v_x; __pyx_t_21 = __pyx_v_y; __pyx_t_22 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_20 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_21 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_18 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_19 * __pyx_v_rgb_array_copy.strides[2]) ))); } } } } } } #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 }
4719:
4720:
4721:
4722:
4723: @cython.boundscheck(False)
4724: @cython.wraparound(False)
4725: @cython.nonecheck(False)
4726: @cython.cdivision(False)
4727: # e.g horizontal_glitch(surface, 0.5, 0.08, frame % 20)
+4728: cdef inline void shader_horizontal_glitch24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_horizontal_glitch24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_rad1_, float __pyx_v_frequency_, float __pyx_v_amplitude_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; float __pyx_v_rad; float __pyx_v_angle; float __pyx_v_angle1; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_ii; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_horizontal_glitch24_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_horizontal_glitch24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __Pyx_RefNannyFinishContext(); }
4729: unsigned char [:, :, :] rgb_array_,
4730: float rad1_,
4731: float frequency_,
4732: float amplitude_):
4733:
4734: """
4735: SHADER GLITCH EFFECT
4736:
4737: Deform the pygame display to create a glitch appearance
4738:
4739: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4740: please refer to pygame function pixels3d or array3d to convert an image into a
4741: 3d array (library surfarray)
4742:
4743: :param rgb_array_: numpy.ndarray shape (w, h, 3) uint8 containing RGB pixels
4744: :param rad1_ : float; Angle in radians, this value control the angle variation over the time
4745: :param frequency_: float; signal frequency, factor that amplify the angle variation
4746: :param amplitude_: float; cos amplitude value
4747: :return:
4748: """
4749: cdef Py_ssize_t w, h
+4750: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
4751:
4752: cdef:
+4753: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
+4754: float rad = <float>(3.14/180.0)
__pyx_v_rad = ((float)(3.14 / 180.0));
+4755: float angle = 0
__pyx_v_angle = 0.0;
+4756: float angle1 = 0
__pyx_v_angle1 = 0.0;
+4757: unsigned char [:, :, :] rgb_array_copy = numpy.array(rgb_array_, copy=True)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 4757, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 4757, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb_array_copy = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+4758: int ii=0
__pyx_v_ii = 0;
4759:
+4760: 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_L4_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L5:; } }
4761:
+4762: for j in range(h):
__pyx_t_3 = __pyx_v_h; __pyx_t_2 = __pyx_t_3; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_2; __pyx_t_9+=1) { __pyx_v_j = __pyx_t_9;
4763:
+4764: for i in range(w):
__pyx_t_10 = __pyx_v_w; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_i = __pyx_t_12;
4765:
+4766: ii = (i + <int>(<float>cos(angle) * amplitude_))
__pyx_v_ii = (__pyx_v_i + ((int)(((float)cos(__pyx_v_angle)) * __pyx_v_amplitude_)));
+4767: if ii > <int>w - 1:
__pyx_t_13 = ((__pyx_v_ii > (((int)__pyx_v_w) - 1)) != 0); if (__pyx_t_13) { /* … */ }
+4768: ii = <int>w - 1
__pyx_v_ii = (((int)__pyx_v_w) - 1);
+4769: if ii < 0:
__pyx_t_13 = ((__pyx_v_ii < 0) != 0); if (__pyx_t_13) { /* … */ }
+4770: ii = 0
__pyx_v_ii = 0;
4771:
+4772: rgb_array_[i, j, 0],\
__pyx_t_16 = __pyx_v_i; __pyx_t_15 = __pyx_v_j; __pyx_t_14 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_17;
+4773: rgb_array_[i, j, 1],\
__pyx_t_14 = __pyx_v_i; __pyx_t_15 = __pyx_v_j; __pyx_t_16 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_18;
+4774: rgb_array_[i, j, 2] = rgb_array_copy[ii, j, 0],\
__pyx_t_14 = __pyx_v_ii; __pyx_t_15 = __pyx_v_j; __pyx_t_16 = 0; __pyx_t_17 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[2]) ))); /* … */ __pyx_t_16 = __pyx_v_i; __pyx_t_15 = __pyx_v_j; __pyx_t_14 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_t_19; }
+4775: rgb_array_copy[ii, j, 1], rgb_array_copy[ii, j, 2]
__pyx_t_16 = __pyx_v_ii; __pyx_t_15 = __pyx_v_j; __pyx_t_14 = 1; __pyx_t_18 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[2]) ))); __pyx_t_14 = __pyx_v_ii; __pyx_t_15 = __pyx_v_j; __pyx_t_16 = 2; __pyx_t_19 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[2]) )));
4776:
+4777: angle1 = angle1 + frequency_ * rad
__pyx_v_angle1 = (__pyx_v_angle1 + (__pyx_v_frequency_ * __pyx_v_rad));
+4778: angle = angle + (rad1_ * rad + rand() % angle1 - rand() % angle1)
__pyx_t_12 = rand(); if (unlikely(__pyx_v_angle1 == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "float divmod()"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 4778, __pyx_L4_error) } __pyx_t_20 = rand(); if (unlikely(__pyx_v_angle1 == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "float divmod()"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 4778, __pyx_L4_error) } __pyx_v_angle = (__pyx_v_angle + (((__pyx_v_rad1_ * __pyx_v_rad) + __Pyx_mod_float(__pyx_t_12, __pyx_v_angle1)) - __Pyx_mod_float(__pyx_t_20, __pyx_v_angle1))); } }
4779:
4780:
4781:
4782:
4783: @cython.boundscheck(False)
4784: @cython.wraparound(False)
4785: @cython.nonecheck(False)
4786: @cython.cdivision(True)
+4787: cdef inline void shader_bpf24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_bpf24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, struct __pyx_opt_args_6shader_shader_bpf24_inplace_c *__pyx_optional_args) { int __pyx_v_threshold = ((int)0x80); Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; float __pyx_v_lum; float __pyx_v_c; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_bpf24_inplace_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold = __pyx_optional_args->threshold; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_WriteUnraisable("shader.shader_bpf24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_bpf24_inplace_c { int __pyx_n; int threshold; int transpose; };
4788: unsigned char [:, :, :] rgb_array_, int threshold = 128, bint transpose=False):
4789: """
4790: SHADER BRIGHT PASS FILTER (INPLACE)
4791:
4792: Conserve only the brightest pixels in an array
4793:
4794: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4795: please refer to pygame function pixels3d or array3d to convert an image into a
4796: 3d array (library surfarray)
4797:
4798: :param rgb_array_: numpy.ndarray shape (w, h, 3) uint8 containing RGB pixels
4799: :param threshold : integer; Bright pass threshold default 128
4800: :param transpose : bool; True| False transpose the final array
4801: :return : void
4802: """
4803:
+4804: assert 0 <= threshold <= 255, "Argument threshold must be in range [0 ... 255]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (0 <= __pyx_v_threshold); if (__pyx_t_1) { __pyx_t_1 = (__pyx_v_threshold <= 0xFF); } if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_threshold_must_be_in_ra); __PYX_ERR(1, 4804, __pyx_L1_error) } } #endif
4805:
4806: cdef:
4807: Py_ssize_t w, h
+4808: w, h = rgb_array_.shape[:2]
__pyx_t_2 = __pyx_v_rgb_array_.shape; __pyx_t_3 = (__pyx_t_2[0]); __pyx_t_4 = (__pyx_t_2[1]); __pyx_v_w = __pyx_t_3; __pyx_v_h = __pyx_t_4;
4809:
4810: cdef:
+4811: int i = 0, j = 0
__pyx_v_i = 0; __pyx_v_j = 0;
4812: float lum, c
4813: unsigned char *r
4814: unsigned char *g
4815: unsigned char *b
4816:
+4817: 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:; } }
+4818: for j in prange(0, h, schedule='static', num_threads=THREADS):
__pyx_t_4 = __pyx_v_h; 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_5 = (__pyx_t_4 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_c) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_lum) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_4 = __pyx_v_h; 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_5 = (__pyx_t_4 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_c) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_lum) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_3); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_c = ((float)__PYX_NAN()); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_lum = ((float)__PYX_NAN()); __pyx_v_r = ((unsigned char *)1);
+4819: for i in range(0, w):
__pyx_t_6 = __pyx_v_w; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
4820:
4821: # ITU-R BT.601 luma coefficients
+4822: r = &rgb_array_[i, j, 0]
__pyx_t_9 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_11 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_9 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[2]) ))));
+4823: g = &rgb_array_[i, j, 1]
__pyx_t_11 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_9 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_11 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_9 * __pyx_v_rgb_array_.strides[2]) ))));
+4824: b = &rgb_array_[i, j, 2]
__pyx_t_9 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_11 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_9 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[2]) ))));
4825:
+4826: lum = r[0] * <float>0.299 + g[0] * <float>0.587 + b[0] * <float>0.114
__pyx_v_lum = ((((__pyx_v_r[0]) * ((float)0.299)) + ((__pyx_v_g[0]) * ((float)0.587))) + ((__pyx_v_b[0]) * ((float)0.114)));
4827:
+4828: if lum > threshold:
__pyx_t_1 = ((__pyx_v_lum > __pyx_v_threshold) != 0); if (__pyx_t_1) { /* … */ goto __pyx_L12; }
+4829: c = (lum - threshold) / lum
__pyx_v_c = ((__pyx_v_lum - __pyx_v_threshold) / __pyx_v_lum);
+4830: r[0] = <unsigned char>(r[0] * c)
(__pyx_v_r[0]) = ((unsigned char)((__pyx_v_r[0]) * __pyx_v_c));
+4831: g[0] = <unsigned char>(g[0] * c)
(__pyx_v_g[0]) = ((unsigned char)((__pyx_v_g[0]) * __pyx_v_c));
+4832: b[0] = <unsigned char>(b[0] * c)
(__pyx_v_b[0]) = ((unsigned char)((__pyx_v_b[0]) * __pyx_v_c));
4833: else:
+4834: r[0], g[0], b[0] = 0, 0, 0
/*else*/ { __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; (__pyx_v_r[0]) = __pyx_t_12; (__pyx_v_g[0]) = __pyx_t_13; (__pyx_v_b[0]) = __pyx_t_14; } __pyx_L12:; } } } } } } #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 }
4835:
4836:
4837:
4838: @cython.boundscheck(False)
4839: @cython.wraparound(False)
4840: @cython.nonecheck(False)
4841: @cython.cdivision(True)
+4842: cdef inline bpf24_c(
static CYTHON_INLINE PyObject *__pyx_f_6shader_bpf24_c(__Pyx_memviewslice __pyx_v_input_array_, struct __pyx_opt_args_6shader_bpf24_c *__pyx_optional_args) { int __pyx_v_threshold = ((int)0x80); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; float __pyx_v_lum; float __pyx_v_c; __Pyx_memviewslice __pyx_v_output_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bpf24_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_threshold = __pyx_optional_args->threshold; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __PYX_XDEC_MEMVIEW(&__pyx_t_12, 1); __Pyx_AddTraceback("shader.bpf24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_output_array_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+4843: unsigned char [:, :, :] input_array_,
struct __pyx_opt_args_6shader_bpf24_c { int __pyx_n; int threshold; int transpose; };
4844: int threshold = 128,
4845: bint transpose=False):
4846: """
4847: SHADER BRIGHT PASS FILTER
4848:
4849: Conserve only the brightest pixels in an array
4850:
4851: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
4852: please refer to pygame function pixels3d or array3d to convert an image into a
4853: 3d array (library surfarray)
4854:
4855: :param input_array_: numpy.ndarray shape (w, h, 3) uint8 containing RGB pixels
4856: :param threshold : float Bright pass threshold default 128
4857: :param transpose : bool; True| False transpose the final array
4858: :return : Return the modified array shape (w, h, 3) uint8
4859: """
+4860: assert 0 <= threshold <= 255, "Argument threshold must be in range [0 ... 255]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (0 <= __pyx_v_threshold); if (__pyx_t_1) { __pyx_t_1 = (__pyx_v_threshold <= 0xFF); } if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_threshold_must_be_in_ra); __PYX_ERR(1, 4860, __pyx_L1_error) } } #endif
4861:
4862: cdef:
4863: Py_ssize_t w, h
+4864: w, h = input_array_.shape[:2]
__pyx_t_2 = __pyx_v_input_array_.shape; __pyx_t_3 = (__pyx_t_2[0]); __pyx_t_4 = (__pyx_t_2[1]); __pyx_v_w = __pyx_t_3; __pyx_v_h = __pyx_t_4;
4865:
4866: cdef:
+4867: int i = 0, j = 0
__pyx_v_i = 0; __pyx_v_j = 0;
4868: float lum, c
+4869: unsigned char [:, :, :] output_array_ = numpy.zeros((h, w, 3), uint8)
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_int_3); __pyx_t_6 = 0; __pyx_t_8 = 0; __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_uint8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_9, __pyx_t_8}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_9, __pyx_t_8}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_11 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_10, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_10, __pyx_t_8); __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_12 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_12.memview)) __PYX_ERR(1, 4869, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_output_array_ = __pyx_t_12; __pyx_t_12.memview = NULL; __pyx_t_12.data = NULL;
4870: unsigned char *r
4871: unsigned char *g
4872: unsigned char *b
4873:
+4874: 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:; } }
+4875: for j in prange(0, h, schedule='static', num_threads=THREADS):
__pyx_t_4 = __pyx_v_h; 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_13 = (__pyx_t_4 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_13 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_c) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_lum) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_4 = __pyx_v_h; 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_13 = (__pyx_t_4 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_13 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_c) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_lum) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_13; __pyx_t_3++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_3); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_c = ((float)__PYX_NAN()); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_lum = ((float)__PYX_NAN()); __pyx_v_r = ((unsigned char *)1);
+4876: for i in range(0, w):
__pyx_t_14 = __pyx_v_w; __pyx_t_15 = __pyx_t_14; for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_15; __pyx_t_10+=1) { __pyx_v_i = __pyx_t_10;
4877:
4878: # ITU-R BT.601 luma coefficients
+4879: r = &input_array_[i, j, 0]
__pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_input_array_.data + __pyx_t_16 * __pyx_v_input_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_input_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_input_array_.strides[2]) ))));
+4880: g = &input_array_[i, j, 1]
__pyx_t_18 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_16 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_input_array_.data + __pyx_t_18 * __pyx_v_input_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_input_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_input_array_.strides[2]) ))));
+4881: b = &input_array_[i, j, 2]
__pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_j; __pyx_t_18 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_input_array_.data + __pyx_t_16 * __pyx_v_input_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_input_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_input_array_.strides[2]) ))));
4882:
+4883: lum = r[0] * <float>0.299 + g[0] * <float>0.587 + b[0] * <float>0.114
__pyx_v_lum = ((((__pyx_v_r[0]) * ((float)0.299)) + ((__pyx_v_g[0]) * ((float)0.587))) + ((__pyx_v_b[0]) * ((float)0.114)));
4884:
+4885: if lum > threshold:
__pyx_t_1 = ((__pyx_v_lum > __pyx_v_threshold) != 0); if (__pyx_t_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 }
+4886: c = (lum - threshold) / lum
__pyx_v_c = ((__pyx_v_lum - __pyx_v_threshold) / __pyx_v_lum);
+4887: output_array_[j, i, 0] = <unsigned char>(r[0] * c)
__pyx_t_18 = __pyx_v_j; __pyx_t_17 = __pyx_v_i; __pyx_t_16 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array_.data + __pyx_t_18 * __pyx_v_output_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_output_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_output_array_.strides[2]) )) = ((unsigned char)((__pyx_v_r[0]) * __pyx_v_c));
+4888: output_array_[j, i, 1] = <unsigned char>(g[0] * c)
__pyx_t_16 = __pyx_v_j; __pyx_t_17 = __pyx_v_i; __pyx_t_18 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array_.data + __pyx_t_16 * __pyx_v_output_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_output_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_output_array_.strides[2]) )) = ((unsigned char)((__pyx_v_g[0]) * __pyx_v_c));
+4889: output_array_[j, i, 2] = <unsigned char>(b[0] * c)
__pyx_t_18 = __pyx_v_j; __pyx_t_17 = __pyx_v_i; __pyx_t_16 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_output_array_.data + __pyx_t_18 * __pyx_v_output_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_output_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_output_array_.strides[2]) )) = ((unsigned char)((__pyx_v_b[0]) * __pyx_v_c));
4890:
+4891: return pygame.image.frombuffer(output_array_, (w, h), 'RGB')
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pygame); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_image); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __pyx_memoryview_fromslice(__pyx_v_output_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_9); __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_10 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_11, __pyx_t_6, __pyx_n_s_RGB}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[4] = {__pyx_t_9, __pyx_t_11, __pyx_t_6, __pyx_n_s_RGB}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_10, 3+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_9) { __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_10, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_10, __pyx_t_6); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_10, __pyx_n_s_RGB); __pyx_t_11 = 0; __pyx_t_6 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
4892:
4893:
4894:
4895: @cython.boundscheck(False)
4896: @cython.wraparound(False)
4897: @cython.nonecheck(False)
4898: @cython.cdivision(True)
+4899: cdef inline void shader_bloom_effect_array24_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_bloom_effect_array24_c(PyObject *__pyx_v_surface_, int __pyx_v_threshold_, struct __pyx_opt_args_6shader_shader_bloom_effect_array24_c *__pyx_optional_args) { /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __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_14, 1); __Pyx_XDECREF(__pyx_t_16); __Pyx_WriteUnraisable("shader.shader_bloom_effect_array24_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_XDECREF(__pyx_v_surface_cp); __Pyx_XDECREF(__pyx_v_s2); __Pyx_XDECREF(__pyx_v_s2_array); __Pyx_XDECREF(__pyx_v_b2_blurred); __Pyx_XDECREF(__pyx_v_s4); __Pyx_XDECREF(__pyx_v_s4_array); __Pyx_XDECREF(__pyx_v_b4_blurred); __Pyx_XDECREF(__pyx_v_s8); __Pyx_XDECREF(__pyx_v_s8_array); __Pyx_XDECREF(__pyx_v_b8_blurred); __Pyx_XDECREF(__pyx_v_s16); __Pyx_XDECREF(__pyx_v_s16_array); __Pyx_XDECREF(__pyx_v_b16_blurred); __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_shader_bloom_effect_array24_c { int __pyx_n; int fast_; };
4900: surface_,
4901: int threshold_,
+4902: bint fast_ = False):
int __pyx_v_fast_ = ((int)0); Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; CYTHON_UNUSED int __pyx_v_bit_size; int __pyx_v_w2; int __pyx_v_h2; int __pyx_v_w4; int __pyx_v_h4; int __pyx_v_w8; int __pyx_v_h8; int __pyx_v_w16; int __pyx_v_h16; int __pyx_v_x2; int __pyx_v_x4; int __pyx_v_x8; int __pyx_v_x16; PyObject *__pyx_v_surface_cp = NULL; PyObject *__pyx_v_s2 = NULL; PyObject *__pyx_v_s2_array = NULL; PyObject *__pyx_v_b2_blurred = NULL; PyObject *__pyx_v_s4 = NULL; PyObject *__pyx_v_s4_array = NULL; PyObject *__pyx_v_b4_blurred = NULL; PyObject *__pyx_v_s8 = NULL; PyObject *__pyx_v_s8_array = NULL; PyObject *__pyx_v_b8_blurred = NULL; PyObject *__pyx_v_s16 = NULL; PyObject *__pyx_v_s16_array = NULL; PyObject *__pyx_v_b16_blurred = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_bloom_effect_array24_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_fast_ = __pyx_optional_args->fast_; } }
4903: """
4904: CREATE A BLOOM EFFECT
4905:
4906: * Surface must be a pygame Surface 24-32 bit format
4907:
4908: :param surface_ : pygame.Surface; Game display or texture
4909: :param threshold_ : integer; Threshold value uint8 in range [0 ... 255].
4910: The threshold value is used by a bright
4911: pass filter to determine the bright pixels above the given threshold.
4912: Below 128 the bloom effect will be more
4913: noticeable and above 128 a bit less.
4914: :param fast_ : bool; True | False; If True the bloom effect will be approximated
4915: and only the x16 subsurface
4916: will be processed to maximize the overall processing time, default is False).
4917: :return : void
4918: """
4919:
+4920: assert 0 <= threshold_ <= 255, "Argument threshold must be in range [0 ... 255]"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (0 <= __pyx_v_threshold_); if (__pyx_t_1) { __pyx_t_1 = (__pyx_v_threshold_ <= 0xFF); } if (unlikely(!(__pyx_t_1 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_threshold_must_be_in_ra); __PYX_ERR(1, 4920, __pyx_L1_error) } } #endif
4921:
4922: cdef:
4923: Py_ssize_t w, h
4924: int bit_size
4925: int w2, h2, w4, h4, w8, h8, w16, h16
+4926: bint x2, x4, x8, x16 = False
__pyx_v_x16 = 0;
4927:
+4928: w, h = surface_.get_size()
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; 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(1, 4928, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(1, 4928, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 4928, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_4); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 4928, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_w = __pyx_t_7; __pyx_v_h = __pyx_t_8;
+4929: bit_size = surface_.get_bitsize()
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bitsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4929, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4929, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 4929, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_bit_size = __pyx_t_9;
4930:
+4931: 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_L7; } __pyx_L7:; } }
+4932: w2, h2 = <int>w >> 1, <int>h >> 1
__pyx_t_10 = (((int)__pyx_v_w) >> 1); __pyx_t_11 = (((int)__pyx_v_h) >> 1); __pyx_v_w2 = __pyx_t_10; __pyx_v_h2 = __pyx_t_11;
+4933: w4, h4 = w2 >> 1, h2 >> 1
__pyx_t_11 = (__pyx_v_w2 >> 1); __pyx_t_10 = (__pyx_v_h2 >> 1); __pyx_v_w4 = __pyx_t_11; __pyx_v_h4 = __pyx_t_10;
+4934: w8, h8 = w4 >> 1, h4 >> 1
__pyx_t_10 = (__pyx_v_w4 >> 1); __pyx_t_11 = (__pyx_v_h4 >> 1); __pyx_v_w8 = __pyx_t_10; __pyx_v_h8 = __pyx_t_11;
+4935: w16, h16 = w8 >> 1, h8 >> 1
__pyx_t_11 = (__pyx_v_w8 >> 1); __pyx_t_10 = (__pyx_v_h8 >> 1); __pyx_v_w16 = __pyx_t_11; __pyx_v_h16 = __pyx_t_10; }
4936:
+4937: 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_L10; } __pyx_L10:; } }
+4938: if w2 > 0 and h2 > 0:
__pyx_t_12 = ((__pyx_v_w2 > 0) != 0); if (__pyx_t_12) { } else { __pyx_t_1 = __pyx_t_12; goto __pyx_L12_bool_binop_done; } __pyx_t_12 = ((__pyx_v_h2 > 0) != 0); __pyx_t_1 = __pyx_t_12; __pyx_L12_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L11; }
+4939: x2 = True
__pyx_v_x2 = 1;
4940: else:
+4941: x2 = False
/*else*/ { __pyx_v_x2 = 0; } __pyx_L11:;
4942:
+4943: if w4 > 0 and h4 > 0:
__pyx_t_12 = ((__pyx_v_w4 > 0) != 0); if (__pyx_t_12) { } else { __pyx_t_1 = __pyx_t_12; goto __pyx_L15_bool_binop_done; } __pyx_t_12 = ((__pyx_v_h4 > 0) != 0); __pyx_t_1 = __pyx_t_12; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L14; }
+4944: x4 = True
__pyx_v_x4 = 1;
4945: else:
+4946: x4 = False
/*else*/ { __pyx_v_x4 = 0; } __pyx_L14:;
4947:
+4948: if w8 > 0 and h8 > 0:
__pyx_t_12 = ((__pyx_v_w8 > 0) != 0); if (__pyx_t_12) { } else { __pyx_t_1 = __pyx_t_12; goto __pyx_L18_bool_binop_done; } __pyx_t_12 = ((__pyx_v_h8 > 0) != 0); __pyx_t_1 = __pyx_t_12; __pyx_L18_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L17; }
+4949: x8 = True
__pyx_v_x8 = 1;
4950: else:
+4951: x8 = False
/*else*/ { __pyx_v_x8 = 0; } __pyx_L17:;
4952:
+4953: if w16 > 0 and h16 > 0:
__pyx_t_12 = ((__pyx_v_w16 > 0) != 0); if (__pyx_t_12) { } else { __pyx_t_1 = __pyx_t_12; goto __pyx_L21_bool_binop_done; } __pyx_t_12 = ((__pyx_v_h16 > 0) != 0); __pyx_t_1 = __pyx_t_12; __pyx_L21_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L20; }
+4954: x16 = True
__pyx_v_x16 = 1;
4955: else:
+4956: x16 = False
/*else*/ { __pyx_v_x16 = 0; } __pyx_L20:; }
4957:
4958: # SUBSURFACE DOWNSCALE CANNOT
4959: # BE PERFORMED AND WILL RAISE AN EXCEPTION
+4960: if not x2:
__pyx_t_1 = ((!(__pyx_v_x2 != 0)) != 0); if (__pyx_t_1) { /* … */ }
+4961: return
goto __pyx_L0;
4962:
+4963: if fast_:
__pyx_t_1 = (__pyx_v_fast_ != 0); if (__pyx_t_1) { /* … */ }
+4964: x2, x4, x8 = False, False, False
__pyx_t_1 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_v_x2 = __pyx_t_1; __pyx_v_x4 = __pyx_t_12; __pyx_v_x8 = __pyx_t_13;
4965:
+4966: surface_cp = bpf24_c(pixels3d(surface_), threshold=threshold_)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(1, 4966, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_15.__pyx_n = 1; __pyx_t_15.threshold = __pyx_v_threshold_; __pyx_t_2 = __pyx_f_6shader_bpf24_c(__pyx_t_14, &__pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1); __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL; __pyx_v_surface_cp = __pyx_t_2; __pyx_t_2 = 0;
4967:
4968:
4969: # FIRST SUBSURFACE DOWNSCALE x2
4970: # THIS IS THE MOST EXPENSIVE IN TERM OF PROCESSING TIME
+4971: if x2:
__pyx_t_13 = (__pyx_v_x2 != 0); if (__pyx_t_13) { /* … */ }
+4972: s2 = scale(surface_cp, (w2, h2))
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_scale); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_w2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_16}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_16}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_v_surface_cp); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_16); __pyx_t_16 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_s2 = __pyx_t_2; __pyx_t_2 = 0;
+4973: s2_array = numpy.array(s2.get_view('3'), dtype=numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s2, __pyx_n_s_get_view); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_16 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_16, __pyx_kp_s_3) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_s_3); __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_numpy); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4973, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_s2_array = __pyx_t_5; __pyx_t_5 = 0;
+4974: shader_blur5x5_array24_inplace_c(s2_array)
__pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_s2_array, PyBUF_WRITABLE); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(1, 4974, __pyx_L1_error) __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_14, NULL); __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1); __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL;
4975: # b2_blurred = frombuffer(numpy.array(s2_array.transpose(1, 0, 2),
4976: # order='C', copy=False), (w2, h2), 'RGB')
+4977: b2_blurred = make_surface(s2_array)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_5 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_s2_array) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_s2_array); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_b2_blurred = __pyx_t_5; __pyx_t_5 = 0;
+4978: s2 = smoothscale(b2_blurred, (w, h))
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_b2_blurred, __pyx_t_16}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_b2_blurred, __pyx_t_16}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif { __pyx_t_3 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_b2_blurred); __Pyx_GIVEREF(__pyx_v_b2_blurred); PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_9, __pyx_v_b2_blurred); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_9, __pyx_t_16); __pyx_t_16 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4978, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_s2, __pyx_t_5); __pyx_t_5 = 0;
+4979: surface_.blit(s2, (0, 0), special_flags=BLEND_RGB_ADD)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_s2); __Pyx_GIVEREF(__pyx_v_s2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s2); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_tuple__12); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_special_flags, __pyx_t_16) < 0) __PYX_ERR(1, 4979, __pyx_L1_error) __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __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; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
4980:
4981: # SECOND SUBSURFACE DOWNSCALE x4
4982: # THIS IS THE SECOND MOST EXPENSIVE IN TERM OF PROCESSING TIME
+4983: if x4:
__pyx_t_13 = (__pyx_v_x4 != 0); if (__pyx_t_13) { /* … */ }
+4984: s4 = scale(surface_cp, (w4, h4))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_scale); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_4}; __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_4}; __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_v_surface_cp); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_9, __pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_9, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_s4 = __pyx_t_16; __pyx_t_16 = 0;
+4985: s4_array = numpy.array(s4.get_view('3'), dtype=numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_numpy); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_array_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_s4, __pyx_n_s_get_view); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_16 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_kp_s_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_16); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_v_s4_array = __pyx_t_5; __pyx_t_5 = 0;
+4986: shader_blur5x5_array24_inplace_c(s4_array)
__pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_s4_array, PyBUF_WRITABLE); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(1, 4986, __pyx_L1_error) __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_14, NULL); __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1); __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL;
4987: # b4_blurred = frombuffer(numpy.array(s4_array.transpose(1, 0, 2),
4988: # order='C', copy=False), (w4, h4), 'RGB')
+4989: b4_blurred = make_surface(s4_array)
__Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_2, __pyx_v_s4_array) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_v_s4_array); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_v_b4_blurred = __pyx_t_5; __pyx_t_5 = 0;
+4990: s4 = smoothscale(b4_blurred, (w, h))
__Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_b4_blurred, __pyx_t_4}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_b4_blurred, __pyx_t_4}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_INCREF(__pyx_v_b4_blurred); __Pyx_GIVEREF(__pyx_v_b4_blurred); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_9, __pyx_v_b4_blurred); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_9, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF_SET(__pyx_v_s4, __pyx_t_5); __pyx_t_5 = 0;
+4991: surface_.blit(s4, (0, 0), special_flags=BLEND_RGB_ADD)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_INCREF(__pyx_v_s4); __Pyx_GIVEREF(__pyx_v_s4); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_v_s4); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_tuple__12); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_special_flags, __pyx_t_4) < 0) __PYX_ERR(1, 4991, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_16, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4992:
4993: # THIRD SUBSURFACE DOWNSCALE x8
+4994: if x8:
__pyx_t_13 = (__pyx_v_x8 != 0); if (__pyx_t_13) { /* … */ }
+4995: s8 = scale(surface_cp, (w8, h8))
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_scale); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = __Pyx_PyInt_From_int(__pyx_v_w8); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5); __pyx_t_16 = 0; __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_3}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_3}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_v_surface_cp); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_9, __pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_9, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_s8 = __pyx_t_4; __pyx_t_4 = 0;
+4996: s8_array = numpy.array(s8.get_view('3'), dtype=numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_s8, __pyx_n_s_get_view); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_3, __pyx_kp_s_3) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_kp_s_3); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_16, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 4996, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_s8_array = __pyx_t_5; __pyx_t_5 = 0;
+4997: shader_blur5x5_array24_inplace_c(s8_array)
__pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_s8_array, PyBUF_WRITABLE); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(1, 4997, __pyx_L1_error) __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_14, NULL); __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1); __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL;
4998: # b8_blurred = frombuffer(numpy.array(s8_array.transpose(1, 0, 2),
4999: # order='C', copy=False), (w8, h8), 'RGB')
+5000: b8_blurred = make_surface(s8_array)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_16 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_5 = (__pyx_t_16) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_16, __pyx_v_s8_array) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_s8_array); __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_b8_blurred = __pyx_t_5; __pyx_t_5 = 0;
+5001: s8 = smoothscale(b8_blurred, (w, h))
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_16 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_16 = 0; __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_b8_blurred, __pyx_t_3}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_b8_blurred, __pyx_t_3}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_16 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_b8_blurred); __Pyx_GIVEREF(__pyx_v_b8_blurred); PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_9, __pyx_v_b8_blurred); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_9, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_s8, __pyx_t_5); __pyx_t_5 = 0;
+5002: surface_.blit(s8, (0, 0), special_flags=BLEND_RGB_ADD)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_s8); __Pyx_GIVEREF(__pyx_v_s8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_s8); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_tuple__12); __pyx_t_16 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_special_flags, __pyx_t_3) < 0) __PYX_ERR(1, 5002, __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_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5002, __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_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5003:
5004: # FOURTH SUBSURFACE DOWNSCALE x16
5005: # LESS SIGNIFICANT IN TERMS OF RENDERING AND PROCESSING TIME
+5006: if x16:
__pyx_t_13 = (__pyx_v_x16 != 0); if (__pyx_t_13) { /* … */ }
+5007: s16 = scale(surface_cp, (w16, h16))
__Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_scale); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_w16); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h16); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_2}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_surface_cp, __pyx_t_2}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_v_surface_cp); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_surface_cp); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5007, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_v_s16 = __pyx_t_3; __pyx_t_3 = 0;
+5008: s16_array = numpy.array(s16.get_view('3'), dtype=numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array_2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_s16, __pyx_n_s_get_view); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_kp_s_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_s_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_s16_array = __pyx_t_5; __pyx_t_5 = 0;
+5009: shader_blur5x5_array24_inplace_c(s16_array)
__pyx_t_14 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_s16_array, PyBUF_WRITABLE); if (unlikely(!__pyx_t_14.memview)) __PYX_ERR(1, 5009, __pyx_L1_error) __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_14, NULL); __PYX_XDEC_MEMVIEW(&__pyx_t_14, 1); __pyx_t_14.memview = NULL; __pyx_t_14.data = NULL;
5010: # b16_blurred = frombuffer(numpy.array(s16_array.transpose(1, 0, 2),
5011: # order='C', copy=False), (w16, h16), 'RGB')
+5012: b16_blurred = make_surface(s16_array)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_s16_array) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_s16_array); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_b16_blurred = __pyx_t_5; __pyx_t_5 = 0;
+5013: s16 = smoothscale(b16_blurred, (w, h))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_16 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_16); __pyx_t_4 = 0; __pyx_t_16 = 0; __pyx_t_16 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_v_b16_blurred, __pyx_t_2}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_v_b16_blurred, __pyx_t_2}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_16) { __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_16); __pyx_t_16 = NULL; } __Pyx_INCREF(__pyx_v_b16_blurred); __Pyx_GIVEREF(__pyx_v_b16_blurred); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_9, __pyx_v_b16_blurred); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_9, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_s16, __pyx_t_5); __pyx_t_5 = 0;
+5014: surface_.blit(s16, (0, 0), special_flags=BLEND_RGB_ADD)
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_s16); __Pyx_GIVEREF(__pyx_v_s16); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s16); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_tuple__12); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_special_flags, __pyx_t_2) < 0) __PYX_ERR(1, 5014, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5015:
5016:
5017: # if mask_ is not None:
5018: # # Multiply mask surface pixels with mask values.
5019: # # RGB pixels = 0 when mask value = 0.0, otherwise
5020: # # modify RGB amplitude
5021: # surface_cp = filtering24_c(surface_cp, mask_)
5022:
5023:
+5024: cdef unsigned int [:, :, ::1] IMAGE_FISHEYE_MODEL = numpy.zeros((800, 1024, 2), uint32)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_33 = PyTuple_New(2); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_INCREF(__pyx_tuple__55); __Pyx_GIVEREF(__pyx_tuple__55); PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_tuple__55); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_33, 1, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_32, __pyx_t_33, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __pyx_t_37 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_37.memview)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_IMAGE_FISHEYE_MODEL, 1); __pyx_v_6shader_IMAGE_FISHEYE_MODEL = __pyx_t_37; __pyx_t_37.memview = NULL; __pyx_t_37.data = NULL; /* … */ __pyx_tuple__55 = PyTuple_Pack(3, __pyx_int_800, __pyx_int_1024, __pyx_int_2); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(1, 5024, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__55); __Pyx_GIVEREF(__pyx_tuple__55);
5025:
5026: @cython.boundscheck(False)
5027: @cython.wraparound(False)
5028: @cython.nonecheck(False)
5029: @cython.cdivision(True)
+5030: cdef inline shader_fisheye24_footprint_c(Py_ssize_t w, Py_ssize_t h):
static CYTHON_INLINE PyObject *__pyx_f_6shader_shader_fisheye24_footprint_c(Py_ssize_t __pyx_v_w, Py_ssize_t __pyx_v_h) { __Pyx_memviewslice __pyx_v_image_fisheye_model = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_y; int __pyx_v_x; CYTHON_UNUSED int __pyx_v_v; float __pyx_v_ny; float __pyx_v_ny2; float __pyx_v_nx; float __pyx_v_nx2; float __pyx_v_r; float __pyx_v_theta; float __pyx_v_nxn; float __pyx_v_nyn; float __pyx_v_nr; int __pyx_v_x2; int __pyx_v_y2; CYTHON_UNUSED float __pyx_v_s; float __pyx_v_c1; float __pyx_v_c2; float __pyx_v_w2; float __pyx_v_h2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_fisheye24_footprint_c", 0); /* … */ /* 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_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_AddTraceback("shader.shader_fisheye24_footprint_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_image_fisheye_model, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
5031:
5032: """
5033: CREATE A FISHEYE MODEL TO HOLD THE PIXEL COORDINATES OF A SURFACE/ GAME DISPLAY
5034:
5035: * The surface and the model must have the same dimensions.
5036:
5037: Store the fisheye model into an external array image_fisheye_model shape (width, height, 2)
5038:
5039: IMAGE_FISHEYE_MODEL contains the fisheye transformation coordinate (x2 & y2) that reference
5040: the final image pixel position (fisheye model)
5041: This method has to be call once before the main loop in order to calculate
5042: the projected position for each pixels.
5043:
5044: :param w : integer; width of the model
5045: :param h : integer; height of the model
5046: :return : Return a numpy.ndarray type (w, h, 2) representing the fisheye model (coordinates
5047: of all surface pixels passing through the fisheye lens model)
5048: """
5049:
+5050: assert w > 0, "Argument w must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_w > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_w_must_be_0); __PYX_ERR(1, 5050, __pyx_L1_error) } } #endif
+5051: assert h > 0, "Argument h must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_h > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_h_must_be_0); __PYX_ERR(1, 5051, __pyx_L1_error) } } #endif
5052:
5053: cdef:
+5054: unsigned int [:, :, :] image_fisheye_model = numpy.zeros((w, h, 2), numpy.uint)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5054, __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_4); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_2); __pyx_t_2 = 0; __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_5, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_5, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_2); __pyx_t_5 = 0; __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5054, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_image_fisheye_model = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+5055: int y=0, x=0, v
__pyx_v_y = 0; __pyx_v_x = 0;
5056: float ny, ny2, nx, nx2, r, theta, nxn, nyn, nr
5057: int x2, y2
+5058: float s = <float>w * <float>h
__pyx_v_s = (((float)__pyx_v_w) * ((float)__pyx_v_h));
+5059: float c1 = <float>2.0 / <float>h
__pyx_v_c1 = (((float)2.0) / ((float)__pyx_v_h));
+5060: float c2 = <float>2.0 / <float>w
__pyx_v_c2 = (((float)2.0) / ((float)__pyx_v_w));
+5061: float w2 = <float>w * <float>0.5
__pyx_v_w2 = (((float)__pyx_v_w) * ((float)0.5));
+5062: float h2 = <float>h * <float>0.5
__pyx_v_h2 = (((float)__pyx_v_h) * ((float)0.5));
5063:
+5064: 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:; } }
+5065: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_9 = __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_11 = (__pyx_t_9 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_nr) lastprivate(__pyx_v_nx) lastprivate(__pyx_v_nx2) lastprivate(__pyx_v_nxn) lastprivate(__pyx_v_ny) lastprivate(__pyx_v_ny2) lastprivate(__pyx_v_nyn) lastprivate(__pyx_v_r) lastprivate(__pyx_v_theta) lastprivate(__pyx_v_v) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) /* … */ __pyx_t_9 = __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_11 = (__pyx_t_9 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_nr) lastprivate(__pyx_v_nx) lastprivate(__pyx_v_nx2) lastprivate(__pyx_v_nxn) lastprivate(__pyx_v_ny) lastprivate(__pyx_v_ny2) lastprivate(__pyx_v_nyn) lastprivate(__pyx_v_r) lastprivate(__pyx_v_theta) lastprivate(__pyx_v_v) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_10); /* Initialize private variables to invalid values */ __pyx_v_nr = ((float)__PYX_NAN()); __pyx_v_nx = ((float)__PYX_NAN()); __pyx_v_nx2 = ((float)__PYX_NAN()); __pyx_v_nxn = ((float)__PYX_NAN()); __pyx_v_ny = ((float)__PYX_NAN()); __pyx_v_ny2 = ((float)__PYX_NAN()); __pyx_v_nyn = ((float)__PYX_NAN()); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_theta = ((float)__PYX_NAN()); __pyx_v_v = ((int)0xbad0bad0); __pyx_v_x2 = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_y2 = ((int)0xbad0bad0);
+5066: nx = x * c2 - <float>1.0
__pyx_v_nx = ((__pyx_v_x * __pyx_v_c2) - ((float)1.0));
+5067: nx2 = nx * nx
__pyx_v_nx2 = (__pyx_v_nx * __pyx_v_nx);
+5068: for y in range(h):
__pyx_t_12 = __pyx_v_h; __pyx_t_13 = __pyx_t_12; for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_13; __pyx_t_6+=1) { __pyx_v_y = __pyx_t_6;
+5069: ny = <float>y * c1 - <float>1.0
__pyx_v_ny = ((((float)__pyx_v_y) * __pyx_v_c1) - ((float)1.0));
+5070: ny2 = ny * ny
__pyx_v_ny2 = (__pyx_v_ny * __pyx_v_ny);
+5071: r = <float>sqrt(nx2 + ny2)
__pyx_v_r = ((float)sqrt((__pyx_v_nx2 + __pyx_v_ny2)));
+5072: if 0.0 <= r <= 1.0:
__pyx_t_14 = (0.0 <= __pyx_v_r); if (__pyx_t_14) { __pyx_t_14 = (__pyx_v_r <= 1.0); } __pyx_t_15 = (__pyx_t_14 != 0); if (__pyx_t_15) { /* … */ } } } } } } } #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 }
+5073: nr = (r + <float>1.0 - <float>sqrt(1.0 - (nx2 + ny2))) * <float>0.5
__pyx_v_nr = (((__pyx_v_r + ((float)1.0)) - ((float)sqrt((1.0 - (__pyx_v_nx2 + __pyx_v_ny2))))) * ((float)0.5));
+5074: if nr <= 1.0:
__pyx_t_15 = ((__pyx_v_nr <= 1.0) != 0); if (__pyx_t_15) { /* … */ }
+5075: theta = <float>atan2(ny, nx)
__pyx_v_theta = ((float)atan2(__pyx_v_ny, __pyx_v_nx));
+5076: nxn = nr * <float>cos(theta)
__pyx_v_nxn = (__pyx_v_nr * ((float)cos(__pyx_v_theta)));
+5077: nyn = nr * <float>sin(theta)
__pyx_v_nyn = (__pyx_v_nr * ((float)sin(__pyx_v_theta)));
+5078: x2 = <int>(nxn * w2 + w2)
__pyx_v_x2 = ((int)((__pyx_v_nxn * __pyx_v_w2) + __pyx_v_w2));
+5079: y2 = <int>(nyn * h2 + h2)
__pyx_v_y2 = ((int)((__pyx_v_nyn * __pyx_v_h2) + __pyx_v_h2));
+5080: v = <int>(y2 * w + x2)
__pyx_v_v = ((int)((__pyx_v_y2 * __pyx_v_w) + __pyx_v_x2));
+5081: image_fisheye_model[x, y, 0] = x2
__pyx_t_16 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_18 = 0; *((unsigned int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_image_fisheye_model.data + __pyx_t_16 * __pyx_v_image_fisheye_model.strides[0]) ) + __pyx_t_17 * __pyx_v_image_fisheye_model.strides[1]) ) + __pyx_t_18 * __pyx_v_image_fisheye_model.strides[2]) )) = __pyx_v_x2;
+5082: image_fisheye_model[x, y, 1] = y2
__pyx_t_18 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_16 = 1; *((unsigned int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_image_fisheye_model.data + __pyx_t_18 * __pyx_v_image_fisheye_model.strides[0]) ) + __pyx_t_17 * __pyx_v_image_fisheye_model.strides[1]) ) + __pyx_t_16 * __pyx_v_image_fisheye_model.strides[2]) )) = __pyx_v_y2;
5083:
+5084: return asarray(ascontiguousarray(image_fisheye_model))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ascontiguousarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_image_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_7 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
5085:
5086: @cython.boundscheck(False)
5087: @cython.wraparound(False)
5088: @cython.nonecheck(False)
5089: @cython.cdivision(True)
+5090: cdef inline void shader_fisheye24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_fisheye24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, __Pyx_memviewslice __pyx_v_fisheye_model) { CYTHON_UNUSED Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned int *__pyx_v_x2; unsigned int *__pyx_v_y2; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_fisheye24_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_fisheye24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __Pyx_RefNannyFinishContext(); }
5091: unsigned char [:, :, :] rgb_array_, unsigned int [:, :, :] fisheye_model):
5092: """
5093: THIS SHADER CAN BE USE TO DISPLAY THE GAME THROUGH A LENS EFFECT
5094:
5095: Display a fisheye effect in real time given a numpy ndarray referencing the
5096: pixels RGB of a Pygame.Surface. In order to accomplish a real time
5097: calculation, this algorithm is using a pre-calculated transformation stored
5098: in the array fisheye_model.
5099: The function shader_fisheye24_footprint_c has to be called prior
5100: shader_fisheye24_inplace_c in order to store the transformation values.
5101:
5102: This shader can be applied directly to the pygame display
5103:
5104: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
5105: please refer to pygame
5106: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
5107:
5108: :param rgb_array_ : numpy.ndarray shape (width, height, 3) containing RGB pixels
5109: :param fisheye_model : numpy.ndarray shape (width, height, 2) int32, fisheye model
5110: containing the pixels
5111: coordinates after the fisheye transformation
5112: :return : void
5113: """
5114:
5115: cdef:
5116: Py_ssize_t w, h
+5117: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
5118:
5119: cdef:
5120: int x, y
+5121: unsigned char [:, :, :] rgb_array_copy = numpy.array(rgb_array_, copy=False, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(1, 5121, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5121, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb_array_copy = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
5122: unsigned int *x2
5123: unsigned int *y2
5124:
+5125: 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:; } }
+5126: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) /* … */ __pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_9; __pyx_t_2++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_x2 = ((unsigned int *)1); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_y2 = ((unsigned int *)1);
+5127: for y in range(h):
__pyx_t_10 = __pyx_v_h; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_y = __pyx_t_12;
+5128: x2 = &fisheye_model[x, y, 0]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; __pyx_v_x2 = (&(*((unsigned int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_fisheye_model.data + __pyx_t_13 * __pyx_v_fisheye_model.strides[0]) ) + __pyx_t_14 * __pyx_v_fisheye_model.strides[1]) ) + __pyx_t_15 * __pyx_v_fisheye_model.strides[2]) ))));
+5129: y2 = &fisheye_model[x, y, 1]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; __pyx_v_y2 = (&(*((unsigned int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_fisheye_model.data + __pyx_t_15 * __pyx_v_fisheye_model.strides[0]) ) + __pyx_t_14 * __pyx_v_fisheye_model.strides[1]) ) + __pyx_t_13 * __pyx_v_fisheye_model.strides[2]) ))));
5130:
+5131: rgb_array_[x, y, 0] = rgb_array_copy[x2[0], y2[0], 0]
__pyx_t_16 = (__pyx_v_x2[0]); __pyx_t_17 = (__pyx_v_y2[0]); __pyx_t_13 = 0; __pyx_t_14 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_18 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_copy.strides[2]) )));
+5132: rgb_array_[x, y, 1] = rgb_array_copy[x2[0], y2[0], 1]
__pyx_t_17 = (__pyx_v_x2[0]); __pyx_t_16 = (__pyx_v_y2[0]); __pyx_t_13 = 1; __pyx_t_18 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_14 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_18 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_17 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_copy.strides[2]) )));
+5133: rgb_array_[x, y, 2] = rgb_array_copy[x2[0], y2[0], 2]
__pyx_t_16 = (__pyx_v_x2[0]); __pyx_t_17 = (__pyx_v_y2[0]); __pyx_t_13 = 2; __pyx_t_14 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_18 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_copy.strides[2]) ))); } } } } } } #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 }
5134:
5135:
5136:
5137: @cython.boundscheck(False)
5138: @cython.wraparound(False)
5139: @cython.nonecheck(False)
5140: @cython.cdivision(True)
+5141: cdef inline tuple shader_rain_footprint_inplace_c(Py_ssize_t w, Py_ssize_t h):
static CYTHON_INLINE PyObject *__pyx_f_6shader_shader_rain_footprint_inplace_c(Py_ssize_t __pyx_v_w, Py_ssize_t __pyx_v_h) { __Pyx_memviewslice __pyx_v_rain_fisheye_model = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_y; int __pyx_v_x; CYTHON_UNUSED int __pyx_v_v; float __pyx_v_ny; float __pyx_v_ny2; float __pyx_v_nx; float __pyx_v_nx2; float __pyx_v_r; float __pyx_v_theta; float __pyx_v_nxn; float __pyx_v_nyn; float __pyx_v_nr; int __pyx_v_x2; int __pyx_v_y2; CYTHON_UNUSED float __pyx_v_s; float __pyx_v_c1; float __pyx_v_c2; float __pyx_v_w2; float __pyx_v_h2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_rain_footprint_inplace_c", 0); /* … */ /* 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_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_AddTraceback("shader.shader_rain_footprint_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rain_fisheye_model, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
5142: """
5143: CREATE A FISH EYE LENS DEFORMATION MAP/TEXTURE
5144:
5145: * This function create a texture and its equivalent numpy.ndarray containing the coordinates
5146: for each pixels after deformation.
5147: * This method must be called once outside of your game main loop
5148: * The model can be re-use to display your video game animation without being re-calculated for
5149: each frame. This method allow a high fps rate
5150:
5151: :param w : integer; Width of the fish eye effect
5152: :param h : integer; height of the fish eye effect
5153: :return : Pygame Surface representing the fish-eye effect and the equivalent numpy.ndarray
5154: """
+5155: assert w > 0, "Argument w must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_w > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_w_must_be_0); __PYX_ERR(1, 5155, __pyx_L1_error) } } #endif
+5156: assert h > 0, "Argument h must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_h > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_h_must_be_0); __PYX_ERR(1, 5156, __pyx_L1_error) } } #endif
5157:
5158: cdef:
+5159: unsigned int [:, :, ::1] rain_fisheye_model = numpy.zeros((w, h, 3), numpy.uint)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5159, __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_4); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __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_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_5, __pyx_t_2}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_5, __pyx_t_2}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_2); __pyx_t_5 = 0; __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5159, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rain_fisheye_model = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+5160: int y=0, x=0, v
__pyx_v_y = 0; __pyx_v_x = 0;
5161: float ny, ny2, nx, nx2, r, theta, nxn, nyn, nr
5162: int x2, y2
+5163: float s = <float>w * <float>h
__pyx_v_s = (((float)__pyx_v_w) * ((float)__pyx_v_h));
+5164: float c1 = <float>2.0 / <float>h
__pyx_v_c1 = (((float)2.0) / ((float)__pyx_v_h));
+5165: float c2 = <float>2.0 / <float>w
__pyx_v_c2 = (((float)2.0) / ((float)__pyx_v_w));
+5166: float w2 = <float>w * <float>0.5
__pyx_v_w2 = (((float)__pyx_v_w) * ((float)0.5));
+5167: float h2 = <float>h * <float>0.5
__pyx_v_h2 = (((float)__pyx_v_h) * ((float)0.5));
5168:
+5169: 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:; } }
+5170: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_9 = __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_11 = (__pyx_t_9 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_nr) lastprivate(__pyx_v_nx) lastprivate(__pyx_v_nx2) lastprivate(__pyx_v_nxn) lastprivate(__pyx_v_ny) lastprivate(__pyx_v_ny2) lastprivate(__pyx_v_nyn) lastprivate(__pyx_v_r) lastprivate(__pyx_v_theta) lastprivate(__pyx_v_v) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) /* … */ __pyx_t_9 = __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_11 = (__pyx_t_9 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_nr) lastprivate(__pyx_v_nx) lastprivate(__pyx_v_nx2) lastprivate(__pyx_v_nxn) lastprivate(__pyx_v_ny) lastprivate(__pyx_v_ny2) lastprivate(__pyx_v_nyn) lastprivate(__pyx_v_r) lastprivate(__pyx_v_theta) lastprivate(__pyx_v_v) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_10); /* Initialize private variables to invalid values */ __pyx_v_nr = ((float)__PYX_NAN()); __pyx_v_nx = ((float)__PYX_NAN()); __pyx_v_nx2 = ((float)__PYX_NAN()); __pyx_v_nxn = ((float)__PYX_NAN()); __pyx_v_ny = ((float)__PYX_NAN()); __pyx_v_ny2 = ((float)__PYX_NAN()); __pyx_v_nyn = ((float)__PYX_NAN()); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_theta = ((float)__PYX_NAN()); __pyx_v_v = ((int)0xbad0bad0); __pyx_v_x2 = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_y2 = ((int)0xbad0bad0);
+5171: nx = x * c2 - <float>1.0
__pyx_v_nx = ((__pyx_v_x * __pyx_v_c2) - ((float)1.0));
+5172: nx2 = nx * nx
__pyx_v_nx2 = (__pyx_v_nx * __pyx_v_nx);
+5173: for y in range(h):
__pyx_t_12 = __pyx_v_h; __pyx_t_13 = __pyx_t_12; for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_13; __pyx_t_6+=1) { __pyx_v_y = __pyx_t_6;
+5174: ny = y * c1 - <float>1.0
__pyx_v_ny = ((__pyx_v_y * __pyx_v_c1) - ((float)1.0));
+5175: ny2 = ny * ny
__pyx_v_ny2 = (__pyx_v_ny * __pyx_v_ny);
+5176: r = <float>sqrt(nx2 + ny2)
__pyx_v_r = ((float)sqrt((__pyx_v_nx2 + __pyx_v_ny2)));
+5177: if 0.0 <= r <= 1.0:
__pyx_t_14 = (0.0 <= __pyx_v_r); if (__pyx_t_14) { __pyx_t_14 = (__pyx_v_r <= 1.0); } __pyx_t_15 = (__pyx_t_14 != 0); if (__pyx_t_15) { /* … */ } } } } } } } #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 }
+5178: nr = (r + <float>1.0 - <float>sqrt(1.0 - (nx2 + ny2))) * <float>0.45
__pyx_v_nr = (((__pyx_v_r + ((float)1.0)) - ((float)sqrt((1.0 - (__pyx_v_nx2 + __pyx_v_ny2))))) * ((float)0.45));
+5179: if nr <= 1.0:
__pyx_t_15 = ((__pyx_v_nr <= 1.0) != 0); if (__pyx_t_15) { /* … */ }
+5180: theta = <float>atan2(ny, nx)
__pyx_v_theta = ((float)atan2(__pyx_v_ny, __pyx_v_nx));
+5181: nxn = nr * <float>cos(theta)
__pyx_v_nxn = (__pyx_v_nr * ((float)cos(__pyx_v_theta)));
+5182: nyn = nr * <float>sin(theta)
__pyx_v_nyn = (__pyx_v_nr * ((float)sin(__pyx_v_theta)));
+5183: x2 = <int>(nxn * w2 + w2)
__pyx_v_x2 = ((int)((__pyx_v_nxn * __pyx_v_w2) + __pyx_v_w2));
+5184: y2 = <int>(nyn * h2 + h2)
__pyx_v_y2 = ((int)((__pyx_v_nyn * __pyx_v_h2) + __pyx_v_h2));
+5185: v = <int>(y2 * w + x2)
__pyx_v_v = ((int)((__pyx_v_y2 * __pyx_v_w) + __pyx_v_x2));
+5186: rain_fisheye_model[x, y, 0] = x2
__pyx_t_16 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_18 = 0; *((unsigned int *) ( /* dim=2 */ ((char *) (((unsigned int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rain_fisheye_model.data + __pyx_t_16 * __pyx_v_rain_fisheye_model.strides[0]) ) + __pyx_t_17 * __pyx_v_rain_fisheye_model.strides[1]) )) + __pyx_t_18)) )) = __pyx_v_x2;
+5187: rain_fisheye_model[x, y, 1] = y2
__pyx_t_18 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_16 = 1; *((unsigned int *) ( /* dim=2 */ ((char *) (((unsigned int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rain_fisheye_model.data + __pyx_t_18 * __pyx_v_rain_fisheye_model.strides[0]) ) + __pyx_t_17 * __pyx_v_rain_fisheye_model.strides[1]) )) + __pyx_t_16)) )) = __pyx_v_y2;
+5188: rain_fisheye_model[x, y, 2] = 0
__pyx_t_16 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_18 = 2; *((unsigned int *) ( /* dim=2 */ ((char *) (((unsigned int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rain_fisheye_model.data + __pyx_t_16 * __pyx_v_rain_fisheye_model.strides[0]) ) + __pyx_t_17 * __pyx_v_rain_fisheye_model.strides[1]) )) + __pyx_t_18)) )) = 0;
5189:
+5190: return make_surface(asarray(rain_fisheye_model)), asarray(rain_fisheye_model)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_rain_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_7 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_asarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_rain_fisheye_model, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5190, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_r = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L0;
5191:
5192:
5193: @cython.boundscheck(False)
5194: @cython.wraparound(False)
5195: @cython.nonecheck(False)
5196: @cython.cdivision(True)
+5197: cdef inline void shader_rain_fisheye24_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_rain_fisheye24_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, __Pyx_memviewslice __pyx_v_rain_fisheye_model) { CYTHON_UNUSED Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned int *__pyx_v_x2; unsigned int *__pyx_v_y2; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_rain_fisheye24_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.shader_rain_fisheye24_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __Pyx_RefNannyFinishContext(); }
5198: unsigned char [:, :, :] rgb_array_,
5199: unsigned int [:, :, ::1] rain_fisheye_model
5200: ):
5201: """
5202: THIS SHADER CAN BE USED TO SIMULATE RAIN DROPLET OR BUBBLE DISPLAYED ON THE TOP OF
5203: THE SCREEN SURFACE.
5204:
5205: Both array rgb_array_ and rain_fisheye_model must have the same size
5206:
5207: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
5208: please refer to pygame
5209: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
5210:
5211: 1) Always call the method shader_rain_footprint_inplace_c before the main loop.
5212: The transformation model doesn't have to be calculated every frames.
5213: The above method will generate a pygame texture (24bit) containing the location
5214: of each pixels after deformation. It does also return a numpy.ndarray equivalent
5215: pixel format that can be used instead of the surface if needed.
5216:
5217: It uses a fish eye lens deformation to reproduce the deformed background image onto
5218: the final image. The operation apply inplace and the surface referenced by the rgb_array_
5219: will be modified directly.
5220: The fish-eye lens deformation will recreate you game scene into the rain droplet or bubble
5221: and create the illusion of animation inside the bubble.
5222:
5223: * This shader cannot be applied directly to the pygame display as the array passed to the
5224: function is a scaled format of the pygame.display (copy not referencing directly the
5225: surface pixels)
5226:
5227: * This algorithm use a pre-calculated fish-eye lens deformation model to boost the overall
5228: fps performances, the texture pixel is then transformed with the model without any intensive
5229: math calculation.
5230:
5231: :param rgb_array_ : numpy.ndarray type (w, h, 3) uint8 (unsigned char 0...255)
5232: Array referencing a
5233: pygame surface (compatible with 24bit format only RGB model)
5234: :param rain_fisheye_model : numpy.ndarray type (w, h, 3) unsigned int containing the
5235: the coordinate for each pixels
5236: :return : void
5237: """
5238:
5239: cdef:
5240: Py_ssize_t w, h
+5241: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
5242:
5243: cdef:
5244: int x, y
+5245: unsigned char [:, :, ::1] rgb_array_copy = numpy.array(rgb_array_, copy=True, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 5245, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5245, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5245, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb_array_copy = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
5246: unsigned int *x2
5247: unsigned int *y2
5248:
+5249: 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:; } }
+5250: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) /* … */ __pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_y) lastprivate(__pyx_v_y2) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_9; __pyx_t_2++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_x2 = ((unsigned int *)1); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_y2 = ((unsigned int *)1);
+5251: for y in range(h):
__pyx_t_10 = __pyx_v_h; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_y = __pyx_t_12;
+5252: x2 = &rain_fisheye_model[x, y, 0]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; __pyx_v_x2 = (&(*((unsigned int *) ( /* dim=2 */ ((char *) (((unsigned int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rain_fisheye_model.data + __pyx_t_13 * __pyx_v_rain_fisheye_model.strides[0]) ) + __pyx_t_14 * __pyx_v_rain_fisheye_model.strides[1]) )) + __pyx_t_15)) ))));
+5253: y2 = &rain_fisheye_model[x, y, 1]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; __pyx_v_y2 = (&(*((unsigned int *) ( /* dim=2 */ ((char *) (((unsigned int *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rain_fisheye_model.data + __pyx_t_15 * __pyx_v_rain_fisheye_model.strides[0]) ) + __pyx_t_14 * __pyx_v_rain_fisheye_model.strides[1]) )) + __pyx_t_13)) ))));
5254:
+5255: rgb_array_[x, y, 0] = rgb_array_copy[x2[0], y2[0], 0]
__pyx_t_16 = (__pyx_v_x2[0]); __pyx_t_17 = (__pyx_v_y2[0]); __pyx_t_13 = 0; __pyx_t_14 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_18 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_13)) )));
+5256: rgb_array_[x, y, 1] = rgb_array_copy[x2[0], y2[0], 1]
__pyx_t_17 = (__pyx_v_x2[0]); __pyx_t_16 = (__pyx_v_y2[0]); __pyx_t_13 = 1; __pyx_t_18 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_14 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_18 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_17 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_13)) )));
+5257: rgb_array_[x, y, 2] = rgb_array_copy[x2[0], y2[0], 2]
__pyx_t_16 = (__pyx_v_x2[0]); __pyx_t_17 = (__pyx_v_y2[0]); __pyx_t_13 = 2; __pyx_t_14 = __pyx_v_x; __pyx_t_15 = __pyx_v_y; __pyx_t_18 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_18 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_16 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_copy.strides[1]) )) + __pyx_t_13)) ))); } } } } } } #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 }
5258:
5259:
5260:
5261:
5262:
5263: @cython.boundscheck(False)
5264: @cython.wraparound(False)
5265: @cython.nonecheck(False)
5266: @cython.cdivision(True)
+5267: cdef inline void shader_tv_scanline_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_tv_scanline_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, int __pyx_v_frame_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; int __pyx_v_j; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; int __pyx_v_frame_2; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_tv_scanline_inplace_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
5268: unsigned char [:, :, :] rgb_array_,
5269: int frame_):
5270: """
5271: SHADER CREATING A TV SCANLINE EFFECT ON PYGAME SURFACE
5272:
5273: The space between each scanline can by adjusted with the frame_ value.
5274: The scanline intensity/colors is lower that the original pixel value
5275:
5276: * This shader can be apply directly to the pygame display as long as rgb_array_ array reference
5277: directly the screen pixels
5278:
5279: The Array (rgb_array) must be a numpy array shape (w, h, 3) containing RGB pixels,
5280: please refer to pygame
5281: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
5282:
5283: :param rgb_array_ : numpy.ndarray shape (w, h, 3) containing RGB pixels
5284: :param frame_ : integer; Frame numbre (linear value)
5285: :return : void
5286: """
5287:
5288:
5289: cdef:
5290: Py_ssize_t w, h
+5291: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
5292:
5293: cdef:
5294: int x, y, j
5295: unsigned char *r
5296: unsigned char *g
5297: unsigned char *b
+5298: int frame_2 = frame_ >> 1
__pyx_v_frame_2 = (__pyx_v_frame_ >> 1);
5299:
+5300: 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:; } }
+5301: for y in prange(0, h, frame_, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; __pyx_t_4 = __pyx_v_frame_; if ((__pyx_t_4 == 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_5 = (__pyx_t_3 - 0 + __pyx_t_4 - __pyx_t_4/abs(__pyx_t_4)) / __pyx_t_4; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) __pyx_t_4 = __pyx_v_frame_; if ((__pyx_t_4 == 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_5 = (__pyx_t_3 - 0 + __pyx_t_4 - __pyx_t_4/abs(__pyx_t_4)) / __pyx_t_4; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_5; __pyx_t_2++){ { __pyx_v_y = (int)(0 + __pyx_t_4 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_x = ((int)0xbad0bad0);
+5302: for x in range(w):
__pyx_t_6 = __pyx_v_w; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_x = __pyx_t_8;
+5303: for j in range(frame_2):
__pyx_t_9 = __pyx_v_frame_2; __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_j = __pyx_t_11;
+5304: if y + j < h - 1:
__pyx_t_12 = (((__pyx_v_y + __pyx_v_j) < (__pyx_v_h - 1)) != 0); if (__pyx_t_12) { /* … */ goto __pyx_L14; }
+5305: r = &rgb_array_[x, y + j, 0]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + __pyx_v_j); __pyx_t_15 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
+5306: g = &rgb_array_[x, y + j, 1]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + __pyx_v_j); __pyx_t_13 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) ))));
+5307: b = &rgb_array_[x, y + j, 2]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + __pyx_v_j); __pyx_t_15 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
5308: else:
+5309: r = &rgb_array_[x, y, 0]
/*else*/ { __pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) ))));
+5310: g = &rgb_array_[x, y, 1]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
+5311: b = &rgb_array_[x, y, 2]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )))); } __pyx_L14:;
+5312: r[0] = <unsigned char> (r[0] * <float>0.65)
(__pyx_v_r[0]) = ((unsigned char)((__pyx_v_r[0]) * ((float)0.65)));
+5313: g[0] = <unsigned char> (g[0] * <float>0.65)
(__pyx_v_g[0]) = ((unsigned char)((__pyx_v_g[0]) * ((float)0.65)));
+5314: b[0] = <unsigned char> (b[0] * <float>0.65)
(__pyx_v_b[0]) = ((unsigned char)((__pyx_v_b[0]) * ((float)0.65))); } } } } } } } #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 }
5315:
5316:
5317: @cython.binding(False)
5318: @cython.boundscheck(False)
5319: @cython.wraparound(False)
5320: @cython.nonecheck(False)
5321: @cython.cdivision(True)
+5322: cdef inline void shader_rgb_split_inplace_c(object surface_, int offset_):
static CYTHON_INLINE void __pyx_f_6shader_shader_rgb_split_inplace_c(PyObject *__pyx_v_surface_, int __pyx_v_offset_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; int __pyx_v_z; __Pyx_memviewslice __pyx_v_rgb = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_red = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_green = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_blue = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_rgb_split_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __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_8); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_WriteUnraisable("shader.shader_rgb_split_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_red, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_green, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_blue, 1); __Pyx_RefNannyFinishContext(); }
5323: """
5324: THIS SHADER CREATE AN RGB SPLIT EFFECT (SUPERPOSED CHANNEL R, G, B WITH GIVEN OFFSET)
5325: The transformation apply inplace
5326:
5327: The original surface will be used and used for the subsurface blit operation.
5328: Each channels will be blit sequentially in the following order RGB
5329: Note that channel green and blue will be blit with an additional flag BLEND_RGB_ADD, to mix
5330: the channel with the lower layers.
5331:
5332: * FPS BOOST
5333: In order to boost the fps frame rate the original surface to process can be downscale x2
5334: and rescale after processing.
5335:
5336: * This shader can be apply directly to the pygame display by passing the screen equ
5337: surface to the
5338: method. This is true if the surface passed to the method is not a screen copy or a
5339: modified/altered
5340: surface (e.g downscale / upscale surface)
5341:
5342: :param surface_ : pygame Surface to process (24bit format)
5343: :param offset_ : integer; offset to add to each channels RGB
5344: :return : void
5345: """
5346: cdef:
5347: Py_ssize_t w, h
+5348: w, h = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 5348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 5348, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 5348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 5348, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 5348, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5348, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5348, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
5349:
5350: cdef:
5351: int i, j
+5352: int z = <int>h * <int>w * 3
__pyx_v_z = ((((int)__pyx_v_h) * ((int)__pyx_v_w)) * 3);
+5353: unsigned char [:] rgb = numpy.frombuffer(surface_.get_buffer(), dtype=numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5353, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_rgb = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
+5354: unsigned char [:] red = numpy.zeros(z, uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_z); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_8 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5354, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __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; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5354, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_red = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
+5355: unsigned char [:] green = numpy.zeros(z, uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_z); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_uint8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5355, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __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_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5355, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_green = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
+5356: unsigned char [:] blue = numpy.zeros(z, uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_z); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_8 = 0; __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5356, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5356, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_blue = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
5357:
5358:
+5359: 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_L7; } __pyx_L7:; } }
5360:
+5361: for i in prange(0, w * h * 4, 4, schedule='static', num_threads=THREADS, chunksize=8):
__pyx_t_7 = ((__pyx_v_w * __pyx_v_h) * 4); if ((4 == 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_10 = (__pyx_t_7 - 0 + 4 - 4/abs(4)) / 4; if (__pyx_t_10 > 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) __pyx_t_11 = 8; /* … */ __pyx_t_7 = ((__pyx_v_w * __pyx_v_h) * 4); if ((4 == 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_10 = (__pyx_t_7 - 0 + 4 - 4/abs(4)) / 4; if (__pyx_t_10 > 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, __pyx_t_11) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_10; __pyx_t_6++){ { __pyx_v_i = (int)(0 + 4 * __pyx_t_6); /* Initialize private variables to invalid values */ __pyx_v_j = ((int)0xbad0bad0);
+5362: j = (i >> 2) * 3
__pyx_v_j = ((__pyx_v_i >> 2) * 3);
+5363: red[j] = rgb[i + 2]
__pyx_t_12 = (__pyx_v_i + 2); __pyx_t_13 = __pyx_v_j; *((unsigned char *) ( /* dim=0 */ (__pyx_v_red.data + __pyx_t_13 * __pyx_v_red.strides[0]) )) = (*((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_12 * __pyx_v_rgb.strides[0]) )));
+5364: green[j+1] = rgb[i + 1]
__pyx_t_12 = (__pyx_v_i + 1); __pyx_t_13 = (__pyx_v_j + 1); *((unsigned char *) ( /* dim=0 */ (__pyx_v_green.data + __pyx_t_13 * __pyx_v_green.strides[0]) )) = (*((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_12 * __pyx_v_rgb.strides[0]) )));
+5365: blue[j+2] = rgb[i ]
__pyx_t_12 = __pyx_v_i; __pyx_t_13 = (__pyx_v_j + 2); *((unsigned char *) ( /* dim=0 */ (__pyx_v_blue.data + __pyx_t_13 * __pyx_v_blue.strides[0]) )) = (*((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_12 * __pyx_v_rgb.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 }
5366:
+5367: del rgb
__PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1);
+5368: surface_.blit(fromstring(bytes(red), (w, h), 'RGB'), (0, 0))
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_red, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_14 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_15 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_15)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_15); __pyx_t_4 = 0; __pyx_t_15 = 0; __pyx_t_15 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_t_14, __pyx_t_16, __pyx_n_s_RGB}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[4] = {__pyx_t_15, __pyx_t_14, __pyx_t_16, __pyx_n_s_RGB}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_15) { __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_15); __pyx_t_15 = NULL; } __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_t_16); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_14 = 0; __pyx_t_16 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5368, __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_t_3 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_2, __pyx_tuple__12}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_2, __pyx_tuple__12}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_t_2); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_tuple__12); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5368, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+5369: surface_.blit(fromstring(bytes(green), (w, h), 'RGB'), (offset_, offset_),
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_green, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_16); __pyx_t_2 = 0; __pyx_t_16 = 0; __pyx_t_16 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_16, __pyx_t_3, __pyx_t_14, __pyx_n_s_RGB}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_16, __pyx_t_3, __pyx_t_14, __pyx_n_s_RGB}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif { __pyx_t_2 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_16) { __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_16); __pyx_t_16 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_11, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_11, __pyx_t_14); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_2, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_3 = 0; __pyx_t_14 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_offset_); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_offset_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_2); __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_14); __pyx_t_1 = 0; __pyx_t_14 = 0; /* … */ __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_2, __pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+5370: special_flags=BLEND_RGB_ADD)
__pyx_t_14 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_special_flags, __pyx_t_1) < 0) __PYX_ERR(1, 5370, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+5371: surface_.blit(fromstring(bytes(blue), (w, h), 'RGB'), (offset_ << 1, offset_ << 1),
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __pyx_memoryview_fromslice(__pyx_v_blue, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_3); __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_11 = 0; 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_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_4, __pyx_t_16, __pyx_n_s_RGB}; __pyx_t_14 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_4, __pyx_t_16, __pyx_n_s_RGB}; __pyx_t_14 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } else #endif { __pyx_t_8 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_t_16); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_4 = 0; __pyx_t_16 = 0; __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_offset_ << 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyInt_From_long((__pyx_v_offset_ << 1)); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_8); __pyx_t_2 = 0; __pyx_t_8 = 0; __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_16); __pyx_t_14 = 0; __pyx_t_16 = 0; /* … */ __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, __pyx_t_16); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+5372: special_flags=BLEND_RGB_ADD)
__pyx_t_16 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_special_flags, __pyx_t_14) < 0) __PYX_ERR(1, 5372, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
5373:
5374:
5375:
5376: @cython.binding(False)
5377: @cython.boundscheck(False)
5378: @cython.wraparound(False)
5379: @cython.nonecheck(False)
5380: @cython.cdivision(True)
+5381: cdef shader_rgb_split_c(object surface_, int offset_):
static PyObject *__pyx_f_6shader_shader_rgb_split_c(PyObject *__pyx_v_surface_, int __pyx_v_offset_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_i; int __pyx_v_j; int __pyx_v_z; __Pyx_memviewslice __pyx_v_rgb = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_red = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_green = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_blue = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_new_surface = NULL; PyObject *__pyx_v_red_ = NULL; PyObject *__pyx_v_green_ = NULL; PyObject *__pyx_v_blue_ = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_rgb_split_c", 0); /* … */ /* 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_8); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("shader.shader_rgb_split_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_red, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_green, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_blue, 1); __Pyx_XDECREF(__pyx_v_new_surface); __Pyx_XDECREF(__pyx_v_red_); __Pyx_XDECREF(__pyx_v_green_); __Pyx_XDECREF(__pyx_v_blue_); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
5382: """
5383: THIS SHADER CREATE AN RGB SPLIT EFFECT (SUPERPOSED CHANNEL R, G, B WITH GIVEN OFFSET)
5384:
5385: The final image has a different width and height since the offset value is removed to keep only
5386: the overlapping R, G, B channels
5387: Setting the Offset_ to zero will have no effect to the original image.
5388:
5389: :param surface_ : pygame Surface to process (24bit format)
5390: :param offset_ : integer; offset to add to each channels RGB
5391: :return : void
5392: """
5393:
5394: cdef:
5395: Py_ssize_t w, h
+5396: w, h = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 5396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 5396, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 5396, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 5396, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 5396, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5396, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5396, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
5397:
5398: cdef:
5399: int i, j
+5400: int z = <int>h * <int>w * 3
__pyx_v_z = ((((int)__pyx_v_h) * ((int)__pyx_v_w)) * 3);
+5401: unsigned char [:] rgb = numpy.frombuffer(surface_.get_buffer(), dtype=numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5401, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_rgb = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
+5402: unsigned char [:] red = numpy.zeros(z, uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_z); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __pyx_t_8 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5402, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __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; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5402, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_red = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
+5403: unsigned char [:] green = numpy.zeros(z, uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_z); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_uint8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5403, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __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_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5403, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_green = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
+5404: unsigned char [:] blue = numpy.zeros(z, uint8, order='C')
__Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_numpy); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_z); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_uint8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_8 = 0; __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 5404, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_ds_unsigned_char(__pyx_t_8, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5404, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_blue = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
5405:
5406: # Create a new surface (sizes - offset)
+5407: new_surface = Surface((w-offset_, h-offset_))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Surface); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyInt_FromSsize_t((__pyx_v_w - __pyx_v_offset_)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_h - __pyx_v_offset_)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_8 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_new_surface = __pyx_t_8; __pyx_t_8 = 0;
+5408: new_surface.convert()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_surface, __pyx_n_s_convert); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_8 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5409:
+5410: 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_L7; } __pyx_L7:; } }
5411:
+5412: for i in prange(0, w * h * 4, 4, schedule='static', num_threads=THREADS, chunksize=8):
__pyx_t_7 = ((__pyx_v_w * __pyx_v_h) * 4); if ((4 == 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_10 = (__pyx_t_7 - 0 + 4 - 4/abs(4)) / 4; if (__pyx_t_10 > 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) __pyx_t_11 = 8; /* … */ __pyx_t_7 = ((__pyx_v_w * __pyx_v_h) * 4); if ((4 == 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_10 = (__pyx_t_7 - 0 + 4 - 4/abs(4)) / 4; if (__pyx_t_10 > 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, __pyx_t_11) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_10; __pyx_t_6++){ { __pyx_v_i = (int)(0 + 4 * __pyx_t_6); /* Initialize private variables to invalid values */ __pyx_v_j = ((int)0xbad0bad0);
+5413: j = (i >> 2) * 3
__pyx_v_j = ((__pyx_v_i >> 2) * 3);
+5414: red[j] = rgb[i + 2]
__pyx_t_12 = (__pyx_v_i + 2); __pyx_t_13 = __pyx_v_j; *((unsigned char *) ( /* dim=0 */ (__pyx_v_red.data + __pyx_t_13 * __pyx_v_red.strides[0]) )) = (*((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_12 * __pyx_v_rgb.strides[0]) )));
+5415: green[j+1] = rgb[i + 1]
__pyx_t_12 = (__pyx_v_i + 1); __pyx_t_13 = (__pyx_v_j + 1); *((unsigned char *) ( /* dim=0 */ (__pyx_v_green.data + __pyx_t_13 * __pyx_v_green.strides[0]) )) = (*((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_12 * __pyx_v_rgb.strides[0]) )));
+5416: blue[j+2] = rgb[i ]
__pyx_t_12 = __pyx_v_i; __pyx_t_13 = (__pyx_v_j + 2); *((unsigned char *) ( /* dim=0 */ (__pyx_v_blue.data + __pyx_t_13 * __pyx_v_blue.strides[0]) )) = (*((unsigned char *) ( /* dim=0 */ (__pyx_v_rgb.data + __pyx_t_12 * __pyx_v_rgb.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 }
5417:
+5418: del rgb
__PYX_XDEC_MEMVIEW(&__pyx_v_rgb, 1);
5419:
+5420: red_ = fromstring(bytes(red), (w, h), 'RGB')
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_red, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_2); __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_t_3, __pyx_t_14, __pyx_n_s_RGB}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_2, __pyx_t_3, __pyx_t_14, __pyx_n_s_RGB}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_t_14); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_3 = 0; __pyx_t_14 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_red_ = __pyx_t_8; __pyx_t_8 = 0;
+5421: green_ = fromstring(bytes(green), (w, h), 'RGB')
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_green, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_14 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_14, __pyx_t_2, __pyx_n_s_RGB}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_3, __pyx_t_14, __pyx_t_2, __pyx_n_s_RGB}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_t_2); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_14 = 0; __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_green_ = __pyx_t_8; __pyx_t_8 = 0;
+5422: blue_ = fromstring(bytes(blue), (w, h), 'RGB')
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fromstring); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_blue, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_14 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_14); __pyx_t_4 = 0; __pyx_t_14 = 0; __pyx_t_14 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_t_2, __pyx_t_3, __pyx_n_s_RGB}; __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { PyObject *__pyx_temp[4] = {__pyx_t_14, __pyx_t_2, __pyx_t_3, __pyx_n_s_RGB}; __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_14) { __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_14); __pyx_t_14 = NULL; } __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_t_3); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_blue_ = __pyx_t_8; __pyx_t_8 = 0;
5423:
+5424: new_surface.blit(red_, (-offset_, -offset_), special_flags=BLEND_RGB_ADD)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_surface, __pyx_n_s_blit); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __Pyx_PyInt_From_int((-__pyx_v_offset_)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyInt_From_int((-__pyx_v_offset_)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_red_); __Pyx_GIVEREF(__pyx_v_red_); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_red_); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_special_flags, __pyx_t_1) < 0) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5424, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+5425: new_surface.blit(green_, (0, 0), special_flags=BLEND_RGB_ADD)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_surface, __pyx_n_s_blit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_green_); __Pyx_GIVEREF(__pyx_v_green_); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_green_); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_tuple__12); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_special_flags, __pyx_t_8) < 0) __PYX_ERR(1, 5425, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+5426: new_surface.blit(blue_, (offset_, offset_), special_flags=BLEND_RGB_ADD)
__pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_new_surface, __pyx_n_s_blit); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_offset_); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_offset_); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_blue_); __Pyx_GIVEREF(__pyx_v_blue_); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_blue_); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_BLEND_RGB_ADD); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_special_flags, __pyx_t_4) < 0) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+5427: return new_surface
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_surface); __pyx_r = __pyx_v_new_surface; goto __pyx_L0;
5428:
5429:
+5430: cpdef inline void putmask_c(
static PyObject *__pyx_pw_6shader_137putmask_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_putmask_c(__Pyx_memviewslice __pyx_v_array_, CYTHON_UNUSED Py_ssize_t __pyx_v_rows_, Py_ssize_t __pyx_v_cols_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_putmask_c *__pyx_optional_args) { int __pyx_v_i; int __pyx_v_j; int *__pyx_v_r; int *__pyx_v_g; int *__pyx_v_b; if (__pyx_optional_args) { } /* … */ /* function exit code */ } /* Python wrapper */ static PyObject *__pyx_pw_6shader_137putmask_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_136putmask_c[] = "\n EQUIVALENT METHOD TO numpy.putmask BUT MUCH FASTER FOR OPERATION WITH OPERAND < V_\n\n * Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n numpy.putmask(array_, array_<0, 0) --> putmask_c(array_, w, h, 0)\n\n :param array_ : numpy.ndarray shape (w, h, 3) of integer\n :param rows_ : integer;\n :param cols_ : integer;\n :param v_ : Value for filter < v_\n :return : void\n "; static PyObject *__pyx_pw_6shader_137putmask_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { __Pyx_memviewslice __pyx_v_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; Py_ssize_t __pyx_v_rows_; Py_ssize_t __pyx_v_cols_; int __pyx_v_v_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("putmask_c (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_array,&__pyx_n_s_rows,&__pyx_n_s_cols,&__pyx_n_s_v,0}; PyObject* values[4] = {0,0,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 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_array)) != 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_rows)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("putmask_c", 0, 3, 4, 1); __PYX_ERR(1, 5430, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cols)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("putmask_c", 0, 3, 4, 2); __PYX_ERR(1, 5430, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_v); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "putmask_c") < 0)) __PYX_ERR(1, 5430, __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); 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_array_ = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_int(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_array_.memview)) __PYX_ERR(1, 5431, __pyx_L3_error) __pyx_v_rows_ = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_rows_ == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5431, __pyx_L3_error) __pyx_v_cols_ = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_cols_ == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5431, __pyx_L3_error) if (values[3]) { __pyx_v_v_ = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_v_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5431, __pyx_L3_error) } else { __pyx_v_v_ = ((int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("putmask_c", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 5430, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.putmask_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_136putmask_c(__pyx_self, __pyx_v_array_, __pyx_v_rows_, __pyx_v_cols_, __pyx_v_v_); 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_6shader_136putmask_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_array_, Py_ssize_t __pyx_v_rows_, Py_ssize_t __pyx_v_cols_, int __pyx_v_v_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("putmask_c", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_array_.memview)) { __Pyx_RaiseUnboundLocalError("array_"); __PYX_ERR(1, 5430, __pyx_L1_error) } __pyx_t_1.__pyx_n = 1; __pyx_t_1.v_ = __pyx_v_v_; __pyx_f_6shader_putmask_c(__pyx_v_array_, __pyx_v_rows_, __pyx_v_cols_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.putmask_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_array_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_putmask_c { int __pyx_n; int v_; };
5431: int [:, :, :] array_, Py_ssize_t rows_, Py_ssize_t cols_, int v_=0)nogil:
5432: """
5433: EQUIVALENT METHOD TO numpy.putmask BUT MUCH FASTER FOR OPERATION WITH OPERAND < V_
5434:
5435: * Cython cpdef function, this function can be called directly and do not require a
5436: hook function.
5437:
5438: numpy.putmask(array_, array_<0, 0) --> putmask_c(array_, w, h, 0)
5439:
5440: :param array_ : numpy.ndarray shape (w, h, 3) of integer
5441: :param rows_ : integer;
5442: :param cols_ : integer;
5443: :param v_ : Value for filter < v_
5444: :return : void
5445: """
5446: cdef:
5447: int i, j
5448: int *r
5449: int *g
5450: int *b
5451:
+5452: for i in prange(0, rows_, schedule='static', num_threads=THREADS):
__pyx_t_1 = __pyx_v_rows_; 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_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_1 = __pyx_v_rows_; 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_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #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); /* Initialize private variables to invalid values */ __pyx_v_b = ((int *)1); __pyx_v_g = ((int *)1); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_r = ((int *)1);
+5453: for j in range(0, cols_):
__pyx_t_4 = __pyx_v_cols_; __pyx_t_5 = __pyx_t_4; for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_j = __pyx_t_6;
+5454: r = &array_[i, j, 0]
__pyx_t_7 = __pyx_v_i; __pyx_t_8 = __pyx_v_j; __pyx_t_9 = 0; __pyx_v_r = (&(*((int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_array_.data + __pyx_t_7 * __pyx_v_array_.strides[0]) ) + __pyx_t_8 * __pyx_v_array_.strides[1]) ) + __pyx_t_9 * __pyx_v_array_.strides[2]) ))));
+5455: g = &array_[i, j, 1]
__pyx_t_9 = __pyx_v_i; __pyx_t_8 = __pyx_v_j; __pyx_t_7 = 1; __pyx_v_g = (&(*((int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_array_.data + __pyx_t_9 * __pyx_v_array_.strides[0]) ) + __pyx_t_8 * __pyx_v_array_.strides[1]) ) + __pyx_t_7 * __pyx_v_array_.strides[2]) ))));
+5456: b = &array_[i, j, 2]
__pyx_t_7 = __pyx_v_i; __pyx_t_8 = __pyx_v_j; __pyx_t_9 = 2; __pyx_v_b = (&(*((int *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_array_.data + __pyx_t_7 * __pyx_v_array_.strides[0]) ) + __pyx_t_8 * __pyx_v_array_.strides[1]) ) + __pyx_t_9 * __pyx_v_array_.strides[2]) ))));
+5457: if r[0] < 0:
__pyx_t_10 = (((__pyx_v_r[0]) < 0) != 0); if (__pyx_t_10) { /* … */ } } } } } } } #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
+5458: r[0] = 0
(__pyx_v_r[0]) = 0;
+5459: g[0] = 0
(__pyx_v_g[0]) = 0;
+5460: b[0] = 0
(__pyx_v_b[0]) = 0;
5461:
5462: # if r[0] > 255:
5463: # r[0] = 255
5464: # if g[0] > 255:
5465: # g[0] = 255
5466: # if b[0] > 255:
5467: # b[0] = 255
5468:
5469:
5470:
5471: @cython.binding(False)
5472: @cython.boundscheck(False)
5473: @cython.wraparound(False)
5474: @cython.nonecheck(False)
5475: @cython.cdivision(True)
+5476: cdef inline tuple shader_ripple_c(
static CYTHON_INLINE PyObject *__pyx_f_6shader_shader_ripple_c(CYTHON_UNUSED Py_ssize_t __pyx_v_rows_, CYTHON_UNUSED Py_ssize_t __pyx_v_cols_, __Pyx_memviewslice __pyx_v_previous, __Pyx_memviewslice __pyx_v_current, __Pyx_memviewslice __pyx_v_array) { int __pyx_v_i; int __pyx_v_j; float __pyx_v_data; float *__pyx_v_c; float *__pyx_v_d; unsigned char *__pyx_v_e; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_ripple_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); __Pyx_AddTraceback("shader.shader_ripple_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
5477: Py_ssize_t rows_, Py_ssize_t cols_,
5478: float [:, ::1] previous,
5479: float [:, ::1] current,
5480: unsigned char [:, :, ::1] array,
5481: ):
5482: """
5483: THIS SHADER CREATE A WATER EFFECT ON A PYGAME SURFACE
5484: This version does not include any background deformation to keep a reasonable fps rate
5485:
5486: * GLOBAL VARIABLE CONSIDERATION
5487: Set 3 arrays as global numpy arrays (not in the main loop, these arrays does not have
5488: to be created every frames).
5489:
5490: current = numpy.zeros((width, height), dtype=numpy.float32)
5491: previous = numpy.zeros((width, height), dtype=numpy.float32)
5492: array = numpy.full((width, height, 3), 0, numpy.uint8)
5493:
5494: * ADD A WATER DROP
5495: To add a water drop to the display just add an integer value to the array previous such as
5496: previous[random.randint(0, width - 1), random.randint(0, height - 1)] = 1024
5497: with width and height matching the size of the array (width, height = previous.get_size())
5498:
5499: * PROCESSING TIME
5500: Then update the transformation. The function below will start the blurring process
5501: (flattening the
5502: values across the array to absorb the drop energy ; 1024 in the example above.
5503: Finally the arrays are swapped : current become previous and previous become current
5504: Note that:
5505: 1) w & h must match the array size
5506: 2) previous & current & array must be identical sizes otherwise an error will be thrown
5507:
5508: previous, current, array = shader_ripple_c(w, h, previous, current, array)
5509:
5510: * CREATING THE SURFACE
5511: The array is then transformed into a numpy.ndarray of type uint8 (unsigned char 0..255)
5512: The pygame make_surface method will convert the array type (w, h, 3) into a surface that can
5513: be blit to the active display.
5514: surf = make_surface(asarray(array, dtype=uint8))
5515:
5516: * BLIT
5517:
5518: The newly surface containing the drops can then be added to the current background or
5519: display (blit process).
5520: Both surface should have the same size for a more realistic effect
5521: The special_flag here is BLEND_RGBA_ADD but can be set to a different value to achieve the
5522: special effect needed (BLEND_RGB_MULT, BLEND_RGB_SUB) etc.
5523: Refer to blending modes to understand the math operation behind the flags
5524:
5525: surface_.blit(surf, (0, 0), special_flags=pygame.BLEND_RGBA_ADD)
5526:
5527: * BOOSTING THE FPS
5528: In order to boost the processing time, I downscale the surface prior processing and
5529: upscale it x2 when
5530: the process is done, this method provide an additional overall performance.
5531:
5532: * NOTE this shader cannot be apply to the screen directly (screen referencing
5533: pygame.display.get_surface()),
5534:
5535:
5536: :param rows_ : integer; Array width
5537: :param cols_ : integer; Array height
5538: :param previous : numpy.ndarray type (w, h) type float; array use for the transformation
5539: :param current : numpy.ndarray type (w, h) type float; array use for the transformation
5540: :param array : numpy.ndarray type (w, h, 3) type unsigned char
5541: :return : Return a tuple containing 3 arrays
5542: """
5543:
5544: cdef:
5545: int i, j, a, b
5546: float data
5547: float *c
5548: float *d
5549: unsigned char *e
5550: float r
5551:
+5552: 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:; } }
5553:
+5554: for i in prange(1, rows_ - 1, schedule='static', num_threads=THREADS):
__pyx_t_1 = (__pyx_v_rows_ - 1); 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 - 1 + 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_c) lastprivate(__pyx_v_d) lastprivate(__pyx_v_data) lastprivate(__pyx_v_e) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) schedule(static) /* … */ __pyx_t_1 = (__pyx_v_rows_ - 1); 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 - 1 + 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_c) lastprivate(__pyx_v_d) lastprivate(__pyx_v_data) lastprivate(__pyx_v_e) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){ { __pyx_v_i = (int)(1 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_c = ((float *)1); __pyx_v_d = ((float *)1); __pyx_v_data = ((float)__PYX_NAN()); __pyx_v_e = ((unsigned char *)1); __pyx_v_j = ((int)0xbad0bad0);
+5555: for j in prange(1, cols_ - 1, schedule='static', num_threads=THREADS):
__pyx_t_4 = (__pyx_v_cols_ - 1); if ((1 == 0)) abort(); { __pyx_t_6 = (__pyx_t_4 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_6 > 0) { #if 0 #pragma omp parallel #endif /* _OPENMP */ { #if 0 #pragma omp for lastprivate(__pyx_v_c) lastprivate(__pyx_v_d) lastprivate(__pyx_v_data) lastprivate(__pyx_v_e) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) schedule(static) /* … */ __pyx_t_4 = (__pyx_v_cols_ - 1); if ((1 == 0)) abort(); { __pyx_t_6 = (__pyx_t_4 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_6 > 0) { #if 0 #pragma omp parallel #endif /* _OPENMP */ { #if 0 #pragma omp for lastprivate(__pyx_v_c) lastprivate(__pyx_v_d) lastprivate(__pyx_v_data) lastprivate(__pyx_v_e) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_6; __pyx_t_5++){ { __pyx_v_j = (int)(1 + 1 * __pyx_t_5); /* Initialize private variables to invalid values */ __pyx_v_c = ((float *)1); __pyx_v_d = ((float *)1); __pyx_v_data = ((float)__PYX_NAN()); __pyx_v_e = ((unsigned char *)1);
5556:
5557: # data = <int>(previous[i + 1, j] + previous[i - 1, j] +
5558: # previous[i, j - 1] + previous[i, j + 1]) >> 1
5559:
+5560: data = (previous[i + 1, j] + previous[i - 1, j] +
__pyx_t_7 = (__pyx_v_i + 1); __pyx_t_8 = __pyx_v_j; __pyx_t_9 = (__pyx_v_i - 1); __pyx_t_10 = __pyx_v_j;
+5561: previous[i, j - 1] + previous[i, j + 1]) * <float>0.5
__pyx_t_11 = __pyx_v_i; __pyx_t_12 = (__pyx_v_j - 1); /* … */ __pyx_t_13 = __pyx_v_i; __pyx_t_14 = (__pyx_v_j + 1); /* … */ __pyx_v_data = (((((*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_previous.data + __pyx_t_7 * __pyx_v_previous.strides[0]) )) + __pyx_t_8)) ))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_previous.data + __pyx_t_9 * __pyx_v_previous.strides[0]) )) + __pyx_t_10)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_previous.data + __pyx_t_11 * __pyx_v_previous.strides[0]) )) + __pyx_t_12)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_previous.data + __pyx_t_13 * __pyx_v_previous.strides[0]) )) + __pyx_t_14)) )))) * ((float)0.5));
+5562: c = ¤t[i, j]
__pyx_t_14 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; __pyx_v_c = (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_current.data + __pyx_t_14 * __pyx_v_current.strides[0]) )) + __pyx_t_13)) ))));
+5563: data = data - <float>c[0]
__pyx_v_data = (__pyx_v_data - ((float)(__pyx_v_c[0])));
+5564: data = data - (data * <float>0.011)
__pyx_v_data = (__pyx_v_data - (__pyx_v_data * ((float)0.011)));
+5565: c[0] = data
(__pyx_v_c[0]) = __pyx_v_data;
+5566: d = &previous[i,j]
__pyx_t_13 = __pyx_v_i; __pyx_t_14 = __pyx_v_j; __pyx_v_d = (&(*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_previous.data + __pyx_t_13 * __pyx_v_previous.strides[0]) )) + __pyx_t_14)) ))));
+5567: e = &array[i, j, 0]
__pyx_t_14 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; __pyx_t_12 = 0; __pyx_v_e = (&(*((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_array.data + __pyx_t_14 * __pyx_v_array.strides[0]) ) + __pyx_t_13 * __pyx_v_array.strides[1]) )) + __pyx_t_12)) ))));
+5568: e[0] = <unsigned char> d[0] if d[0] > 0 else 0
if ((((__pyx_v_d[0]) > 0.0) != 0)) { __pyx_t_15 = ((unsigned char)(__pyx_v_d[0])); } else { __pyx_t_15 = 0; } (__pyx_v_e[0]) = __pyx_t_15;
+5569: array[i, j, 1] = e[0]
__pyx_t_12 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; __pyx_t_14 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_array.data + __pyx_t_12 * __pyx_v_array.strides[0]) ) + __pyx_t_13 * __pyx_v_array.strides[1]) )) + __pyx_t_14)) )) = (__pyx_v_e[0]);
+5570: array[i, j, 2] = e[0]
__pyx_t_14 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; __pyx_t_12 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_array.data + __pyx_t_14 * __pyx_v_array.strides[0]) ) + __pyx_t_13 * __pyx_v_array.strides[1]) )) + __pyx_t_12)) )) = (__pyx_v_e[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 }
5571:
+5572: return current, previous, array
__Pyx_XDECREF(__pyx_r); __pyx_t_16 = __pyx_memoryview_fromslice(__pyx_v_current, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 5572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_17 = __pyx_memoryview_fromslice(__pyx_v_previous, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 5572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __pyx_memoryview_fromslice(__pyx_v_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 5572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = PyTuple_New(3); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 5572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_16); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_19, 1, __pyx_t_17); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_19, 2, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_r = ((PyObject*)__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L0;
5573:
5574:
5575:
5576: @cython.binding(False)
5577: @cython.boundscheck(False)
5578: @cython.wraparound(False)
5579: @cython.nonecheck(False)
5580: @cython.cdivision(False)
+5581: cpdef tunnel_modeling32(Py_ssize_t screen_width, Py_ssize_t screen_height):
static PyObject *__pyx_pw_6shader_139tunnel_modeling32(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_tunnel_modeling32(Py_ssize_t __pyx_v_screen_width, Py_ssize_t __pyx_v_screen_height, CYTHON_UNUSED int __pyx_skip_dispatch) { __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_angles = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_shades = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_surface = NULL; int __pyx_v_s_width; int __pyx_v_s_height; __Pyx_memviewslice __pyx_v_scr_data = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_i; double __pyx_v_sqy; double __pyx_v_sqx; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tunnel_modeling32", 0); /* … */ /* 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_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1); __Pyx_AddTraceback("shader.tunnel_modeling32", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_angles, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_shades, 1); __Pyx_XDECREF(__pyx_v_surface); __PYX_XDEC_MEMVIEW(&__pyx_v_scr_data, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_139tunnel_modeling32(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_138tunnel_modeling32[] = "\n THIS METHOD CREATE A TUNNEL MODEL\n\n * This method must be called before rendering the tunnel in order to create\n all the necessary buffers that will be called during the rendering of the tunnel effect.\n tunnel_modeling32 must be call once only before the main loop of your game.\n\n * Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n * The default tunnel texture is internally loaded (the texture is 256x256 pixels 24-bit)\n check the line :\n surface = pygame.image.load(\"Assets\\Graphics\\Background\\space1.jpg\").convert()\n\n * This algorithm uses a 256x256 texture but reshape it to 512x512 pixels for a\n better effect definition\n\n :param screen_width : integer; Game display size (width in pixels)\n :param screen_height : integer; Game display size (height in pixels)\n :return : return a tuple containing the following (distances, angles,\n shades, scr_data)\n distances is a numpy.ndarray buffer containing float values representing the distance\n of each pixels\n angles is a numpy.ndarray buffer containing float values representing the angle of each pixels\n shades is a numpy.ndarray buffer containing float values representing the shade of each pixels\n scr_data is a numpy.ndarray buffer containing uint8 values representing the BGR (not RGB)\n values of each pixels\n\n "; static PyObject *__pyx_pw_6shader_139tunnel_modeling32(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { Py_ssize_t __pyx_v_screen_width; Py_ssize_t __pyx_v_screen_height; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tunnel_modeling32 (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_screen_width,&__pyx_n_s_screen_height,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_screen_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_screen_height)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_modeling32", 1, 2, 2, 1); __PYX_ERR(1, 5581, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tunnel_modeling32") < 0)) __PYX_ERR(1, 5581, __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_screen_width = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_screen_width == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5581, __pyx_L3_error) __pyx_v_screen_height = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_screen_height == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5581, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("tunnel_modeling32", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 5581, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.tunnel_modeling32", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_138tunnel_modeling32(__pyx_self, __pyx_v_screen_width, __pyx_v_screen_height); 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_6shader_138tunnel_modeling32(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_screen_width, Py_ssize_t __pyx_v_screen_height) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tunnel_modeling32", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_6shader_tunnel_modeling32(__pyx_v_screen_width, __pyx_v_screen_height, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5581, __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("shader.tunnel_modeling32", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
5582: """
5583: THIS METHOD CREATE A TUNNEL MODEL
5584:
5585: * This method must be called before rendering the tunnel in order to create
5586: all the necessary buffers that will be called during the rendering of the tunnel effect.
5587: tunnel_modeling32 must be call once only before the main loop of your game.
5588:
5589: * Cython cpdef function, this function can be called directly and do not require a
5590: hook function.
5591:
5592: * The default tunnel texture is internally loaded (the texture is 256x256 pixels 24-bit)
5593: check the line :
5594: surface = pygame.image.load("Assets\\Graphics\\Background\\space1.jpg").convert()
5595:
5596: * This algorithm uses a 256x256 texture but reshape it to 512x512 pixels for a
5597: better effect definition
5598:
5599: :param screen_width : integer; Game display size (width in pixels)
5600: :param screen_height : integer; Game display size (height in pixels)
5601: :return : return a tuple containing the following (distances, angles,
5602: shades, scr_data)
5603: distances is a numpy.ndarray buffer containing float values representing the distance
5604: of each pixels
5605: angles is a numpy.ndarray buffer containing float values representing the angle of each pixels
5606: shades is a numpy.ndarray buffer containing float values representing the shade of each pixels
5607: scr_data is a numpy.ndarray buffer containing uint8 values representing the BGR (not RGB)
5608: values of each pixels
5609:
5610: """
5611:
+5612: assert screen_width > 0, "Argument screen_width must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_screen_width > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_screen_width_must_be_0); __PYX_ERR(1, 5612, __pyx_L1_error) } } #endif
+5613: assert screen_height > 0, "Argument screen_height must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_screen_height > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_screen_height_must_be_0); __PYX_ERR(1, 5613, __pyx_L1_error) } } #endif
5614:
+5615: cdef int [:] distances = numpy.empty((screen_width * screen_height * 4), int32)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyInt_FromSsize_t(((__pyx_v_screen_width * __pyx_v_screen_height) * 4)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_2, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5615, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_distances = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+5616: cdef int [:] angles = numpy.empty((screen_width * screen_height * 4), int32)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyInt_FromSsize_t(((__pyx_v_screen_width * __pyx_v_screen_height) * 4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_t_3, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5616, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_angles = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+5617: cdef int [:] shades = numpy.empty((screen_width * screen_height * 4), int32)
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyInt_FromSsize_t(((__pyx_v_screen_width * __pyx_v_screen_height) * 4)); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_7, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_7, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_3) { __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL; } __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_6, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_6, __pyx_t_4); __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5617, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_shades = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
5618:
+5619: surface = pygame.image.load("../Assets/space1.jpg").convert()
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pygame); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_image); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_load); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_kp_s_Assets_space1_jpg) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_s_Assets_space1_jpg); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_convert); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_surface = __pyx_t_1; __pyx_t_1 = 0;
5620:
+5621: cdef int s_width = 512
__pyx_v_s_width = 0x200;
+5622: cdef int s_height = 512
__pyx_v_s_height = 0x200;
+5623: surface = smoothscale(surface, (s_width, s_height))
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_s_width); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_s_height); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_surface, __pyx_t_7}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_surface, __pyx_t_7}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_surface); __Pyx_GIVEREF(__pyx_v_surface); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_6, __pyx_v_surface); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_6, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_surface, __pyx_t_1); __pyx_t_1 = 0;
+5624: cdef unsigned char [::1] scr_data = surface.get_buffer()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface, __pyx_n_s_get_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); } } __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(1, 5624, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_scr_data = __pyx_t_9; __pyx_t_9.memview = NULL; __pyx_t_9.data = NULL;
5625:
+5626: cdef int x, y, i = 0
__pyx_v_i = 0;
5627:
5628:
+5629: for y in range(0, screen_height * 2):
__pyx_t_10 = (__pyx_v_screen_height * 2); __pyx_t_11 = __pyx_t_10; for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_11; __pyx_t_6+=1) { __pyx_v_y = __pyx_t_6;
+5630: sqy = pow(y - screen_height, 2)
__pyx_v_sqy = pow((__pyx_v_y - __pyx_v_screen_height), 2.0);
+5631: for x in range(0, screen_width * 2):
__pyx_t_12 = (__pyx_v_screen_width * 2); __pyx_t_13 = __pyx_t_12; for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) { __pyx_v_x = __pyx_t_14;
+5632: sqx = pow(x - screen_width, 2)
__pyx_v_sqx = pow((__pyx_v_x - __pyx_v_screen_width), 2.0);
+5633: if (sqx + sqy) == 0:
__pyx_t_15 = (((__pyx_v_sqx + __pyx_v_sqy) == 0.0) != 0); if (__pyx_t_15) { /* … */ goto __pyx_L7; }
+5634: distances[i] = 1
__pyx_t_16 = __pyx_v_i; *((int *) ( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_16 * __pyx_v_distances.strides[0]) )) = 1;
5635: else:
+5636: distances[i] = <int>(floor(
__pyx_t_19 = ((int)floor((__pyx_t_17 / __pyx_t_18))); /* … */ __pyx_t_16 = __pyx_v_i; *((int *) ( /* dim=0 */ (__pyx_v_distances.data + __pyx_t_16 * __pyx_v_distances.strides[0]) )) = __Pyx_mod_int(__pyx_t_19, __pyx_v_s_height); } __pyx_L7:;
+5637: 32 * <float>s_height / <float>sqrt(sqx + sqy))) % s_height
/*else*/ { /* … */ __pyx_t_17 = (32.0 * ((float)__pyx_v_s_height)); /* … */ __pyx_t_18 = ((float)sqrt((__pyx_v_sqx + __pyx_v_sqy))); if (unlikely(__pyx_t_18 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 5637, __pyx_L1_error) } /* … */ if (unlikely(__pyx_v_s_height == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 5637, __pyx_L1_error) }
+5638: angles[i] = <int>round_c(<float>s_width * atan2(y - screen_height,
__pyx_t_20 = (((float)__pyx_v_s_width) * atan2((__pyx_v_y - __pyx_v_screen_height), (__pyx_v_x - __pyx_v_screen_width))); /* … */ __pyx_t_16 = __pyx_v_i; *((int *) ( /* dim=0 */ (__pyx_v_angles.data + __pyx_t_16 * __pyx_v_angles.strides[0]) )) = ((int)round((__pyx_t_20 / ((float)__pyx_v_6shader_M_PI))));
+5639: x - screen_width) / (<float>M_PI))
if (unlikely(((float)__pyx_v_6shader_M_PI) == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 5639, __pyx_L1_error) }
+5640: shades[i] = <int>min(sqrt(sqx + sqy)*10, 255)
__pyx_t_21 = 0xFF; __pyx_t_20 = (sqrt((__pyx_v_sqx + __pyx_v_sqy)) * 10.0); if (((__pyx_t_21 < __pyx_t_20) != 0)) { __pyx_t_22 = __pyx_t_21; } else { __pyx_t_22 = __pyx_t_20; } __pyx_t_16 = __pyx_v_i; *((int *) ( /* dim=0 */ (__pyx_v_shades.data + __pyx_t_16 * __pyx_v_shades.strides[0]) )) = ((int)__pyx_t_22);
+5641: i = i + 1
__pyx_v_i = (__pyx_v_i + 1); } }
5642:
+5643: return distances, angles, shades, scr_data
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_distances, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_angles, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_shades, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_scr_data, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 5643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_7); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_5 = 0; __pyx_t_7 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
5644:
5645:
5646:
5647:
5648: @cython.binding(False)
5649: @cython.boundscheck(False)
5650: @cython.wraparound(False)
5651: @cython.nonecheck(False)
5652: @cython.cdivision(True)
+5653: cpdef tunnel_render32(
static PyObject *__pyx_pw_6shader_141tunnel_render32(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_tunnel_render32(int __pyx_v_t, Py_ssize_t __pyx_v_screen_width, Py_ssize_t __pyx_v_screen_height, int __pyx_v_screen_w2, int __pyx_v_screen_h2, __Pyx_memviewslice __pyx_v_distances, __Pyx_memviewslice __pyx_v_angles, __Pyx_memviewslice __pyx_v_shades, __Pyx_memviewslice __pyx_v_scr_data, __Pyx_memviewslice __pyx_v_dest_array, CYTHON_UNUSED int __pyx_skip_dispatch) { int __pyx_v_s_width; int __pyx_v_s_height; float __pyx_v_timer; int __pyx_v_shiftx; int __pyx_v_shifty; int __pyx_v_centerx; int __pyx_v_centery; int __pyx_v_stride; int __pyx_v_dest_ofs; int __pyx_v_src_ofs; int __pyx_v_u; int __pyx_v_v; int __pyx_v_x; int __pyx_v_y; int __pyx_v_pix_ofs; int __pyx_v_shade; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tunnel_render32", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("shader.tunnel_render32", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_141tunnel_render32(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_140tunnel_render32[] = "\n TUNNEL EFFECT RENDERING METHOD\n\n * Always call the method tunnel_modeling32 outside of your game main loop\n before calling this method (from\n the main loop)\n\n * Return a pygame surface containing the tunnel rendering effect, the image\n is 32 bit (with per-pixel information)\n\n * Cython cpdef function, this function can be called directly and do not\n require a hook function.\n\n * The parameter t must change overtime\n\n :param t : integer; linear value (frame number)\n :param screen_width : integer; Game display size (width in pixels)\n :param screen_height: integer; Game display size (height in pixels)\n :param screen_w2 : integer; Game display width / 2.0\n :param screen_h2 : integer; game display height / 2.0\n :param distances : numpy.ndarray buffer containing float values\n representing the distance of each pixels\n :param angles : numpy.ndarray buffer containing float values\n representing the angle of each pixels\n :param shades : numpy.ndarray buffer containing float values\n representing the shade of each pixels\n :param scr_data : numpy.ndarray buffer containing float values\n representing the BGR values of each pixels\n :param dest_array : numpy.ndarray buffer containing float values\n representing the RGB values of each pixels\n :return : Return a pygame.Surface (w, h) 32 bit with per-pixel information\n "; static PyObject *__pyx_pw_6shader_141tunnel_render32(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_t; Py_ssize_t __pyx_v_screen_width; Py_ssize_t __pyx_v_screen_height; int __pyx_v_screen_w2; int __pyx_v_screen_h2; __Pyx_memviewslice __pyx_v_distances = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_angles = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_shades = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_scr_data = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_dest_array = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tunnel_render32 (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t_2,&__pyx_n_s_screen_width,&__pyx_n_s_screen_height,&__pyx_n_s_screen_w2,&__pyx_n_s_screen_h2,&__pyx_n_s_distances,&__pyx_n_s_angles,&__pyx_n_s_shades,&__pyx_n_s_scr_data,&__pyx_n_s_dest_array,0}; PyObject* values[10] = {0,0,0,0,0,0,0,0,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 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_t_2)) != 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_screen_width)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 1); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_screen_height)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 2); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_screen_w2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 3); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_screen_h2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 4); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_distances)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 5); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_angles)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 6); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shades)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 7); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_scr_data)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 8); __PYX_ERR(1, 5653, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dest_array)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, 9); __PYX_ERR(1, 5653, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tunnel_render32") < 0)) __PYX_ERR(1, 5653, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 10) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[4] = PyTuple_GET_ITEM(__pyx_args, 4); values[5] = PyTuple_GET_ITEM(__pyx_args, 5); values[6] = PyTuple_GET_ITEM(__pyx_args, 6); values[7] = PyTuple_GET_ITEM(__pyx_args, 7); values[8] = PyTuple_GET_ITEM(__pyx_args, 8); values[9] = PyTuple_GET_ITEM(__pyx_args, 9); } __pyx_v_t = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_t == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5654, __pyx_L3_error) __pyx_v_screen_width = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_screen_width == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5655, __pyx_L3_error) __pyx_v_screen_height = __Pyx_PyIndex_AsSsize_t(values[2]); if (unlikely((__pyx_v_screen_height == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 5656, __pyx_L3_error) __pyx_v_screen_w2 = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_screen_w2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5657, __pyx_L3_error) __pyx_v_screen_h2 = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_screen_h2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5658, __pyx_L3_error) __pyx_v_distances = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[5], PyBUF_WRITABLE); if (unlikely(!__pyx_v_distances.memview)) __PYX_ERR(1, 5659, __pyx_L3_error) __pyx_v_angles = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[6], PyBUF_WRITABLE); if (unlikely(!__pyx_v_angles.memview)) __PYX_ERR(1, 5660, __pyx_L3_error) __pyx_v_shades = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[7], PyBUF_WRITABLE); if (unlikely(!__pyx_v_shades.memview)) __PYX_ERR(1, 5661, __pyx_L3_error) __pyx_v_scr_data = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(values[8], PyBUF_WRITABLE); if (unlikely(!__pyx_v_scr_data.memview)) __PYX_ERR(1, 5662, __pyx_L3_error) __pyx_v_dest_array = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(values[9], PyBUF_WRITABLE); if (unlikely(!__pyx_v_dest_array.memview)) __PYX_ERR(1, 5663, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("tunnel_render32", 1, 10, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 5653, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.tunnel_render32", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_140tunnel_render32(__pyx_self, __pyx_v_t, __pyx_v_screen_width, __pyx_v_screen_height, __pyx_v_screen_w2, __pyx_v_screen_h2, __pyx_v_distances, __pyx_v_angles, __pyx_v_shades, __pyx_v_scr_data, __pyx_v_dest_array); 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_6shader_140tunnel_render32(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_t, Py_ssize_t __pyx_v_screen_width, Py_ssize_t __pyx_v_screen_height, int __pyx_v_screen_w2, int __pyx_v_screen_h2, __Pyx_memviewslice __pyx_v_distances, __Pyx_memviewslice __pyx_v_angles, __Pyx_memviewslice __pyx_v_shades, __Pyx_memviewslice __pyx_v_scr_data, __Pyx_memviewslice __pyx_v_dest_array) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("tunnel_render32", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_distances.memview)) { __Pyx_RaiseUnboundLocalError("distances"); __PYX_ERR(1, 5653, __pyx_L1_error) } if (unlikely(!__pyx_v_angles.memview)) { __Pyx_RaiseUnboundLocalError("angles"); __PYX_ERR(1, 5653, __pyx_L1_error) } if (unlikely(!__pyx_v_shades.memview)) { __Pyx_RaiseUnboundLocalError("shades"); __PYX_ERR(1, 5653, __pyx_L1_error) } if (unlikely(!__pyx_v_scr_data.memview)) { __Pyx_RaiseUnboundLocalError("scr_data"); __PYX_ERR(1, 5653, __pyx_L1_error) } if (unlikely(!__pyx_v_dest_array.memview)) { __Pyx_RaiseUnboundLocalError("dest_array"); __PYX_ERR(1, 5653, __pyx_L1_error) } __pyx_t_1 = __pyx_f_6shader_tunnel_render32(__pyx_v_t, __pyx_v_screen_width, __pyx_v_screen_height, __pyx_v_screen_w2, __pyx_v_screen_h2, __pyx_v_distances, __pyx_v_angles, __pyx_v_shades, __pyx_v_scr_data, __pyx_v_dest_array, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5653, __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("shader.tunnel_render32", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_distances, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_angles, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_shades, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_scr_data, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_dest_array, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
5654: int t,
5655: Py_ssize_t screen_width,
5656: Py_ssize_t screen_height,
5657: int screen_w2,
5658: int screen_h2,
5659: int [::1] distances,
5660: int [::1] angles,
5661: int [::1] shades,
5662: unsigned char [::1] scr_data,
5663: unsigned char [::1] dest_array):
5664:
5665: """
5666: TUNNEL EFFECT RENDERING METHOD
5667:
5668: * Always call the method tunnel_modeling32 outside of your game main loop
5669: before calling this method (from
5670: the main loop)
5671:
5672: * Return a pygame surface containing the tunnel rendering effect, the image
5673: is 32 bit (with per-pixel information)
5674:
5675: * Cython cpdef function, this function can be called directly and do not
5676: require a hook function.
5677:
5678: * The parameter t must change overtime
5679:
5680: :param t : integer; linear value (frame number)
5681: :param screen_width : integer; Game display size (width in pixels)
5682: :param screen_height: integer; Game display size (height in pixels)
5683: :param screen_w2 : integer; Game display width / 2.0
5684: :param screen_h2 : integer; game display height / 2.0
5685: :param distances : numpy.ndarray buffer containing float values
5686: representing the distance of each pixels
5687: :param angles : numpy.ndarray buffer containing float values
5688: representing the angle of each pixels
5689: :param shades : numpy.ndarray buffer containing float values
5690: representing the shade of each pixels
5691: :param scr_data : numpy.ndarray buffer containing float values
5692: representing the BGR values of each pixels
5693: :param dest_array : numpy.ndarray buffer containing float values
5694: representing the RGB values of each pixels
5695: :return : Return a pygame.Surface (w, h) 32 bit with per-pixel information
5696: """
5697:
+5698: assert screen_width > 0, "Argument screen_width must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_screen_width > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_screen_width_must_be_0); __PYX_ERR(1, 5698, __pyx_L1_error) } } #endif
+5699: assert screen_height > 0, "Argument screen_height must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_screen_height > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_screen_height_must_be_0); __PYX_ERR(1, 5699, __pyx_L1_error) } } #endif
+5700: assert screen_w2 > 0, "Argument screen_w2 must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_screen_w2 > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_screen_w2_must_be_0); __PYX_ERR(1, 5700, __pyx_L1_error) } } #endif
+5701: assert screen_h2 > 0, "Argument screen_h2 must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_screen_h2 > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_screen_h2_must_be_0); __PYX_ERR(1, 5701, __pyx_L1_error) } } #endif
5702:
5703: cdef:
+5704: int s_width = 512
__pyx_v_s_width = 0x200;
+5705: int s_height = 512
__pyx_v_s_height = 0x200;
+5706: float timer = t * <float>1e-3
__pyx_v_timer = (__pyx_v_t * ((float)1e-3));
+5707: int shiftx = <int>floor(s_width * timer)
__pyx_v_shiftx = ((int)floor((__pyx_v_s_width * __pyx_v_timer)));
+5708: int shifty = <int>floor(s_height * <float>0.25 * timer)
__pyx_v_shifty = ((int)floor(((__pyx_v_s_height * ((float)0.25)) * __pyx_v_timer)));
+5709: int centerx = <int>(screen_w2 +
__pyx_v_centerx = ((int)(__pyx_v_screen_w2 + ((float)floor(((__pyx_v_screen_w2 >> 1) * ((float)sin((__pyx_v_timer * ((float)0.25)))))))));
5710: <float>floor((screen_w2 >> 1) * <float>sin(timer * <float>0.25)))
+5711: int centery = <int>(screen_h2 + <float>floor(
__pyx_v_centery = ((int)(__pyx_v_screen_h2 + ((float)floor(((__pyx_v_screen_h2 >> 1) * ((float)sin((__pyx_v_timer * ((float)0.5)))))))));
5712: (screen_h2 >> 1) * <float>sin(timer * <float>0.5)))
+5713: int stride = <int>screen_width * 2
__pyx_v_stride = (((int)__pyx_v_screen_width) * 2);
+5714: int dest_ofs = 0
__pyx_v_dest_ofs = 0;
5715: int src_ofs
5716: int u, v, x, y
5717: int pix_ofs, shade
5718:
5719: # with nogil:
5720: # for y in range(0, screen_height):
5721: # srcOfs = y * stride + centerx + centery * stride
5722: # for x in range(0, screen_width):
5723: # u = (distances[srcOfs] + shiftx) & 0xff
5724: # v = (angles[srcOfs] + shifty) & 0xff
5725: # while v < 0:
5726: # v = v + s_height
5727: #
5728: # shade = <int>(shades[srcOfs] * ONE_255)
5729: #
5730: # pixOfs = (u + (v << 9)) << 3
5731: # dest_array[dest_ofs ] = scr_data[pixOfs + 2] * shade
5732: # dest_array[dest_ofs + 1] = scr_data[pixOfs + 1] * shade
5733: # dest_array[dest_ofs + 2] = scr_data[pixOfs + 0] * shade
5734: # dest_array[dest_ofs + 3] = 255 # scr_data[pixOfs + 4] * shade
5735: #
5736: # dest_ofs = dest_ofs + 4
5737: # srcOfs = srcOfs + 1
5738: #
5739: # return pygame.image.frombuffer(dest_array, (screen_width, screen_height), "RGBA")
5740:
+5741: 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:; } }
5742:
+5743: for y in prange(0, screen_height, schedule='static', num_threads=4):
__pyx_t_1 = __pyx_v_screen_height; 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_dest_ofs) lastprivate(__pyx_v_pix_ofs) lastprivate(__pyx_v_shade) lastprivate(__pyx_v_src_ofs) lastprivate(__pyx_v_u) lastprivate(__pyx_v_v) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(4) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_dest_ofs = ((int)0xbad0bad0); __pyx_v_pix_ofs = ((int)0xbad0bad0); __pyx_v_shade = ((int)0xbad0bad0); __pyx_v_src_ofs = ((int)0xbad0bad0); __pyx_v_u = ((int)0xbad0bad0); __pyx_v_v = ((int)0xbad0bad0); __pyx_v_x = ((int)0xbad0bad0);
5744:
+5745: for x in range(0, screen_width):
__pyx_t_4 = __pyx_v_screen_width; __pyx_t_5 = __pyx_t_4; for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_x = __pyx_t_6;
5746:
+5747: src_ofs = y * stride + centerx + centery * stride + x
__pyx_v_src_ofs = ((((__pyx_v_y * __pyx_v_stride) + __pyx_v_centerx) + (__pyx_v_centery * __pyx_v_stride)) + __pyx_v_x);
+5748: dest_ofs = (y * screen_height + x) << 2
__pyx_v_dest_ofs = (((__pyx_v_y * __pyx_v_screen_height) + __pyx_v_x) << 2);
5749:
+5750: u = (distances[src_ofs] + shiftx) & 0xff
__pyx_t_7 = __pyx_v_src_ofs; __pyx_v_u = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_distances.data) + __pyx_t_7)) ))) + __pyx_v_shiftx) & 0xff);
+5751: v = (angles[src_ofs] + shifty) & 0xff
__pyx_t_7 = __pyx_v_src_ofs; __pyx_v_v = (((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_angles.data) + __pyx_t_7)) ))) + __pyx_v_shifty) & 0xff);
5752:
+5753: shade = <int> (shades[src_ofs] * ONE_255)
__pyx_t_7 = __pyx_v_src_ofs; __pyx_v_shade = ((int)((*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_shades.data) + __pyx_t_7)) ))) * 0.00392156862745098));
5754:
+5755: pix_ofs = (u + (v << 9)) << 3
__pyx_v_pix_ofs = ((__pyx_v_u + (__pyx_v_v << 9)) << 3);
5756:
+5757: dest_array[dest_ofs] = scr_data[pix_ofs + 2] * shade
__pyx_t_7 = (__pyx_v_pix_ofs + 2); __pyx_t_8 = __pyx_v_dest_ofs; *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_dest_array.data) + __pyx_t_8)) )) = ((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_scr_data.data) + __pyx_t_7)) ))) * __pyx_v_shade);
+5758: dest_array[dest_ofs + 1] = scr_data[pix_ofs + 1] * shade
__pyx_t_7 = (__pyx_v_pix_ofs + 1); __pyx_t_8 = (__pyx_v_dest_ofs + 1); *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_dest_array.data) + __pyx_t_8)) )) = ((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_scr_data.data) + __pyx_t_7)) ))) * __pyx_v_shade);
+5759: dest_array[dest_ofs + 2] = scr_data[pix_ofs + 0] * shade
__pyx_t_7 = (__pyx_v_pix_ofs + 0); __pyx_t_8 = (__pyx_v_dest_ofs + 2); *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_dest_array.data) + __pyx_t_8)) )) = ((*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_scr_data.data) + __pyx_t_7)) ))) * __pyx_v_shade);
+5760: dest_array[dest_ofs + 3] = 255
__pyx_t_7 = (__pyx_v_dest_ofs + 3); *((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_dest_array.data) + __pyx_t_7)) )) = 0xFF; } } } } } } #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 }
5761:
+5762: return pygame.image.frombuffer(dest_array, (screen_width, screen_height), "RGBA")
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_pygame); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_image); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __pyx_memoryview_fromslice(__pyx_v_dest_array, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = PyInt_FromSsize_t(__pyx_v_screen_width); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyInt_FromSsize_t(__pyx_v_screen_height); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_13); __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_11, __pyx_t_14, __pyx_n_s_RGBA}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[4] = {__pyx_t_13, __pyx_t_11, __pyx_t_14, __pyx_n_s_RGBA}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_6, 3+__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } else #endif { __pyx_t_12 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL; } __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_6, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_6, __pyx_t_14); __Pyx_INCREF(__pyx_n_s_RGBA); __Pyx_GIVEREF(__pyx_n_s_RGBA); PyTuple_SET_ITEM(__pyx_t_12, 2+__pyx_t_6, __pyx_n_s_RGBA); __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 5762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0;
5763:
5764:
5765:
5766:
5767: # @cython.binding(True)
5768: # @cython.boundscheck(True)
5769: # @cython.wraparound(True)
5770: # @cython.nonecheck(True)
5771: # @cython.cdivision(False)
5772: # cpdef tunnel_modeling24(int screen_width, int screen_height):
5773: #
5774: # cdef int [:] distances = numpy.empty((screen_width * screen_height * 3), int32)
5775: # cdef int [:] angles = numpy.empty((screen_width * screen_height * 3), int32)
5776: # cdef int [:] shades = numpy.empty((screen_width * screen_height * 3), int32)
5777: #
5778: # surface = pygame.image.load("Assets\\Graphics\\Background\\space1.jpg").convert()
5779: #
5780: # cdef int s_width = 512
5781: # cdef int s_height = 512
5782: # surface = pygame.transform.smoothscale(surface, (s_width, s_height))
5783: # cdef unsigned char [:] scr_data = numpy.frombuffer(
5784: # pygame.image.tostring(surface, 'RGB'), uint8).copy()
5785: #
5786: # cdef int x, y, i = 0
5787: #
5788: # for y in range(0, screen_height * 2):
5789: # sqy = pow(y - screen_height, 2)
5790: # for x in range(0, screen_width * 2):
5791: # sqx = pow(x - screen_width, 2)
5792: #
5793: # i /= 4
5794: # i *= 3
5795: # if (sqx + sqy) == 0:
5796: # distances[i] = 1
5797: # else:
5798: # distances[i] = <int>(
5799: # floor(32 * <float>s_height / <float>sqrt(sqx + sqy))) % s_height
5800: # angles[i] = <int>round(
5801: # <float>s_width * atan2(y - screen_height, x - screen_width) / M_PI)
5802: # shades[i] = <int>min(sqrt(sqx + sqy)*10, 255)
5803: # i = i + 1
5804: #
5805: # return distances, angles, shades, scr_data
5806: #
5807:
5808: # @cython.binding(True)
5809: # @cython.boundscheck(True)
5810: # @cython.wraparound(True)
5811: # @cython.nonecheck(True)
5812: # @cython.cdivision(True)
5813: # cpdef tunnel_render24(int t,
5814: # int screen_width,
5815: # int screen_height,
5816: # int screen_w2,
5817: # int screen_h2,
5818: # int [:] distances,
5819: # int [:] angles,
5820: # int [:] shades,
5821: # unsigned char [:] scr_data,
5822: # unsigned char [:] dest_array):
5823: # cdef:
5824: # int s_width = 512
5825: # int s_height = 512
5826: # float timer = t * 1e-3
5827: # int shiftx = <int>floor(s_width * timer)
5828: # int shifty = <int>floor(s_height * 0.25 * timer)
5829: # int centerx = <int>(screen_w2 + floor((screen_w2 >> 1) * sin(timer * 0.25)))
5830: # int centery = <int>(screen_h2 + floor((screen_h2 >> 1) * sin(timer * 0.5)))
5831: # int stride = screen_width * 2
5832: # int destOfs = 0
5833: # int srcOfs
5834: # int u, v, x, y
5835: # int pixOfs, shade
5836: #
5837: #
5838: # with nogil:
5839: #
5840: # for y in prange(0, screen_height, schedule='static', num_threads=THREADS):
5841: # for x in range(0, screen_width):
5842: #
5843: #
5844: # srcOfs = (y * stride * 3 + centerx + centery * stride + x * 3)
5845: #
5846: # destOfs = (y * screen_height*3 + x * 3)
5847: #
5848: #
5849: # u = (distances[srcOfs] + shiftx) & 0xff
5850: # v = (angles[srcOfs] + shifty) & 0xff
5851: #
5852: #
5853: # #shade = <int>(shades[srcOfs] * ONE_255)
5854: #
5855: # pixOfs = (u + (v << 9)) << 1
5856: #
5857: # dest_array[destOfs ] = scr_data[pixOfs + 2] #* shade
5858: # dest_array[destOfs + 1] = scr_data[pixOfs + 1] #* shade
5859: # dest_array[destOfs + 2] = scr_data[pixOfs + 0] #* shade
5860: #
5861: #
5862: # return pygame.image.frombuffer(dest_array, (screen_width, screen_height), "RGB")
5863:
5864:
5865:
5866:
5867:
5868: @cython.binding(False)
5869: @cython.boundscheck(False)
5870: @cython.wraparound(False)
5871: @cython.nonecheck(False)
5872: @cython.cdivision(True)
+5873: cpdef tuple heat_map(int wavelength, float gamma=1.0):
static PyObject *__pyx_pw_6shader_143heat_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_heat_map(int __pyx_v_wavelength, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_heat_map *__pyx_optional_args) { float __pyx_v_gamma = ((float)1.0); struct rgb_color_int __pyx_v_rgb_c; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heat_map", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_gamma = __pyx_optional_args->gamma; } } /* … */ /* 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_AddTraceback("shader.heat_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_143heat_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_142heat_map[] = "\n RETURN AN RGB COLOR VALUE MATCHING A SPECIFIC WAVELENGTH\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n This function return a tuple (R,G,B) corresponding to the\n color wavelength (wavelength_to_rgb is an External C\n routine with pre-defined wavelength such as :\n Color Wavelength(nm) Frequency(THz)\n Red 620-750 484-400\n Orange 590-620 508-484\n Yellow 570-590 526-508\n Green 495-570 606-526\n Blue 450-495 668-606\n Violet 380-450 789-668\n e.g If the routine is called with a wavelength of 620, the returned color\n will be a red gradient\n\n :param wavelength : integer; Wavelength\n :param gamma : float; Gamma value\n :return : tuple RGB values (0 ... 255)\n "; static PyObject *__pyx_pw_6shader_143heat_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_wavelength; float __pyx_v_gamma; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heat_map (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_wavelength,&__pyx_n_s_gamma,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_wavelength)) != 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_gamma); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "heat_map") < 0)) __PYX_ERR(1, 5873, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_wavelength = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_wavelength == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5873, __pyx_L3_error) if (values[1]) { __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 5873, __pyx_L3_error) } else { __pyx_v_gamma = ((float)1.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("heat_map", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 5873, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.heat_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_142heat_map(__pyx_self, __pyx_v_wavelength, __pyx_v_gamma); 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_6shader_142heat_map(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_wavelength, float __pyx_v_gamma) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heat_map", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.gamma = __pyx_v_gamma; __pyx_t_1 = __pyx_f_6shader_heat_map(__pyx_v_wavelength, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5873, __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("shader.heat_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_heat_map { int __pyx_n; float gamma; };
5874: """
5875: RETURN AN RGB COLOR VALUE MATCHING A SPECIFIC WAVELENGTH
5876:
5877: Cython cpdef function, this function can be called directly and do not require a
5878: hook function.
5879:
5880: This function return a tuple (R,G,B) corresponding to the
5881: color wavelength (wavelength_to_rgb is an External C
5882: routine with pre-defined wavelength such as :
5883: Color Wavelength(nm) Frequency(THz)
5884: Red 620-750 484-400
5885: Orange 590-620 508-484
5886: Yellow 570-590 526-508
5887: Green 495-570 606-526
5888: Blue 450-495 668-606
5889: Violet 380-450 789-668
5890: e.g If the routine is called with a wavelength of 620, the returned color
5891: will be a red gradient
5892:
5893: :param wavelength : integer; Wavelength
5894: :param gamma : float; Gamma value
5895: :return : tuple RGB values (0 ... 255)
5896: """
5897: cdef rgb_color_int rgb_c
+5898: rgb_c = wavelength_to_rgb(wavelength, gamma)
__pyx_v_rgb_c = wavelength_to_rgb(__pyx_v_wavelength, __pyx_v_gamma);
+5899: return rgb_c.r, rgb_c.g, rgb_c.b
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.r); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.g); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.b); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
5900:
5901: @cython.binding(False)
5902: @cython.boundscheck(False)
5903: @cython.wraparound(False)
5904: @cython.nonecheck(False)
5905: @cython.cdivision(True)
+5906: cpdef tuple custom_map(int wavelength, int [:] color_array_, float gamma=1.0):
static PyObject *__pyx_pw_6shader_145custom_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_custom_map(int __pyx_v_wavelength, __Pyx_memviewslice __pyx_v_color_array_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_custom_map *__pyx_optional_args) { float __pyx_v_gamma = ((float)1.0); struct rgb_color_int __pyx_v_rgb_c; int *__pyx_v_p; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("custom_map", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_gamma = __pyx_optional_args->gamma; } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("shader.custom_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_145custom_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_144custom_map[] = "\n RETURN AN RGB COLOR VALUE MATCHING A CUSTOM WAVELENGTH\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n This function return a tuple (R,G,B) corresponding to the\n color wavelength define in color_array_\n (wavelength_to_rgb_custom is an External C\n routine with customize wavelength and allow the user to defined\n a customize palette according to an input value)\n\n example for a Fire palette\n arr = numpy.array(\n [0, 1, # violet is not used\n 0, 1, # blue is not used\n 0, 1, # green is not used\n 2, 619, # yellow, return a yellow gradient for values [2...619]\n 620, 650, # orange return a orange gradient for values [620 ... 650]\n 651, 660 # red return a red gradient for values [651 ... 660]\n ], numpy.int)\n\n\n :param wavelength : integer; Wavelength\n :param gamma : float; Gamma value\n :param color_array_ : numpy array containing the min and max of each color (red,\n orange, yellow, green, blue, violet)\n :return : tuple RGB values (0 ... 255)\n "; static PyObject *__pyx_pw_6shader_145custom_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_wavelength; __Pyx_memviewslice __pyx_v_color_array_ = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_gamma; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("custom_map (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_wavelength,&__pyx_n_s_color_array,&__pyx_n_s_gamma,0}; PyObject* values[3] = {0,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 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_wavelength)) != 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_color_array)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("custom_map", 0, 2, 3, 1); __PYX_ERR(1, 5906, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gamma); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "custom_map") < 0)) __PYX_ERR(1, 5906, __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); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_wavelength = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_wavelength == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5906, __pyx_L3_error) __pyx_v_color_array_ = __Pyx_PyObject_to_MemoryviewSlice_ds_int(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_color_array_.memview)) __PYX_ERR(1, 5906, __pyx_L3_error) if (values[2]) { __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[2]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 5906, __pyx_L3_error) } else { __pyx_v_gamma = ((float)1.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("custom_map", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 5906, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.custom_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_144custom_map(__pyx_self, __pyx_v_wavelength, __pyx_v_color_array_, __pyx_v_gamma); 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_6shader_144custom_map(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_wavelength, __Pyx_memviewslice __pyx_v_color_array_, float __pyx_v_gamma) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("custom_map", 0); __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_color_array_.memview)) { __Pyx_RaiseUnboundLocalError("color_array_"); __PYX_ERR(1, 5906, __pyx_L1_error) } __pyx_t_2.__pyx_n = 1; __pyx_t_2.gamma = __pyx_v_gamma; __pyx_t_1 = __pyx_f_6shader_custom_map(__pyx_v_wavelength, __pyx_v_color_array_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5906, __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("shader.custom_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_color_array_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_custom_map { int __pyx_n; float gamma; };
5907: """
5908: RETURN AN RGB COLOR VALUE MATCHING A CUSTOM WAVELENGTH
5909:
5910: Cython cpdef function, this function can be called directly and do not require a
5911: hook function.
5912:
5913: This function return a tuple (R,G,B) corresponding to the
5914: color wavelength define in color_array_
5915: (wavelength_to_rgb_custom is an External C
5916: routine with customize wavelength and allow the user to defined
5917: a customize palette according to an input value)
5918:
5919: example for a Fire palette
5920: arr = numpy.array(
5921: [0, 1, # violet is not used
5922: 0, 1, # blue is not used
5923: 0, 1, # green is not used
5924: 2, 619, # yellow, return a yellow gradient for values [2...619]
5925: 620, 650, # orange return a orange gradient for values [620 ... 650]
5926: 651, 660 # red return a red gradient for values [651 ... 660]
5927: ], numpy.int)
5928:
5929:
5930: :param wavelength : integer; Wavelength
5931: :param gamma : float; Gamma value
5932: :param color_array_ : numpy array containing the min and max of each color (red,
5933: orange, yellow, green, blue, violet)
5934: :return : tuple RGB values (0 ... 255)
5935: """
5936: cdef rgb_color_int rgb_c
5937: cdef int *p
+5938: p = &color_array_[0]
__pyx_t_1 = 0; __pyx_v_p = (&(*((int *) ( /* dim=0 */ (__pyx_v_color_array_.data + __pyx_t_1 * __pyx_v_color_array_.strides[0]) ))));
+5939: rgb_c = wavelength_to_rgb_custom(wavelength, p, gamma)
__pyx_v_rgb_c = wavelength_to_rgb_custom(__pyx_v_wavelength, __pyx_v_p, __pyx_v_gamma);
+5940: return rgb_c.r, rgb_c.g, rgb_c.b
__Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.r); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5940, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.g); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5940, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.b); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5940, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 5940, __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_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L0;
5941:
5942:
5943:
5944:
+5945: cdef int i = 0
__pyx_v_6shader_i = 0;
+5946: HEATMAP = [heat_map(i, 1.0) for i in range(380, 750)]
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); for (__pyx_t_7 = 0x17C; __pyx_t_7 < 0x2EE; __pyx_t_7+=1) { __pyx_v_6shader_i = __pyx_t_7; __pyx_t_38.__pyx_n = 1; __pyx_t_38.gamma = 1.0; __pyx_t_33 = __pyx_f_6shader_heat_map(__pyx_v_6shader_i, 0, &__pyx_t_38); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 5946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_33))) __PYX_ERR(1, 5946, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; } if (PyDict_SetItem(__pyx_d, __pyx_n_s_HEATMAP, __pyx_t_2) < 0) __PYX_ERR(1, 5946, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5947:
+5948: cdef float f_map = (<float>750.0 - <float>380.0 -<float>1.0) / (<float>255.0 * <float>3.0)
__pyx_v_6shader_f_map = (((((float)750.0) - ((float)380.0)) - ((float)1.0)) / (((float)255.0) * ((float)3.0)));
5949:
+5950: cdef unsigned char[:, ::1] heatmap_array = numpy.zeros((750 - 380, 3), numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_tuple__56); __Pyx_GIVEREF(__pyx_tuple__56); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_tuple__56); __Pyx_GIVEREF(__pyx_t_32); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_32); __pyx_t_32 = 0; __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_33, __pyx_t_2, NULL); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_39 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_unsigned_char(__pyx_t_32, PyBUF_WRITABLE); if (unlikely(!__pyx_t_39.memview)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_heatmap_array, 1); __pyx_v_6shader_heatmap_array = __pyx_t_39; __pyx_t_39.memview = NULL; __pyx_t_39.data = NULL; /* … */ __pyx_tuple__56 = PyTuple_Pack(2, __pyx_int_370, __pyx_int_3); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(1, 5950, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__56); __Pyx_GIVEREF(__pyx_tuple__56);
5951: cdef tuple t
+5952: i = 0
__pyx_v_6shader_i = 0;
+5953: for t in HEATMAP:
__Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_n_s_HEATMAP); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 5953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); if (likely(PyList_CheckExact(__pyx_t_32)) || PyTuple_CheckExact(__pyx_t_32)) { __pyx_t_2 = __pyx_t_32; __Pyx_INCREF(__pyx_t_2); __pyx_t_40 = 0; __pyx_t_41 = NULL; } else { __pyx_t_40 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_41 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_41)) __PYX_ERR(1, 5953, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; for (;;) { if (likely(!__pyx_t_41)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_40 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_32 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_40); __Pyx_INCREF(__pyx_t_32); __pyx_t_40++; if (unlikely(0 < 0)) __PYX_ERR(1, 5953, __pyx_L1_error) #else __pyx_t_32 = PySequence_ITEM(__pyx_t_2, __pyx_t_40); __pyx_t_40++; if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 5953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); #endif } else { if (__pyx_t_40 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_32 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_40); __Pyx_INCREF(__pyx_t_32); __pyx_t_40++; if (unlikely(0 < 0)) __PYX_ERR(1, 5953, __pyx_L1_error) #else __pyx_t_32 = PySequence_ITEM(__pyx_t_2, __pyx_t_40); __pyx_t_40++; if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 5953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); #endif } } else { __pyx_t_32 = __pyx_t_41(__pyx_t_2); if (unlikely(!__pyx_t_32)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(1, 5953, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_32); } if (!(likely(PyTuple_CheckExact(__pyx_t_32))||((__pyx_t_32) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_32)->tp_name), 0))) __PYX_ERR(1, 5953, __pyx_L1_error) __Pyx_XGOTREF(__pyx_v_6shader_t); __Pyx_DECREF_SET(__pyx_v_6shader_t, ((PyObject*)__pyx_t_32)); __Pyx_GIVEREF(__pyx_t_32); __pyx_t_32 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+5954: heatmap_array[i, 0] = t[0]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 5954, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 0)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 5954, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundLocalError("heatmap_array"); __PYX_ERR(1, 5954, __pyx_L1_error) } __pyx_t_43 = __pyx_v_6shader_i; __pyx_t_44 = 0; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_43 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_44)) )) = __pyx_t_42;
+5955: heatmap_array[i, 1] = t[1]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 5955, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 1)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 5955, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundLocalError("heatmap_array"); __PYX_ERR(1, 5955, __pyx_L1_error) } __pyx_t_44 = __pyx_v_6shader_i; __pyx_t_43 = 1; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_44 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_43)) )) = __pyx_t_42;
+5956: heatmap_array[i, 2] = t[2]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 5956, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 2)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 5956, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundLocalError("heatmap_array"); __PYX_ERR(1, 5956, __pyx_L1_error) } __pyx_t_43 = __pyx_v_6shader_i; __pyx_t_44 = 2; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_43 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_44)) )) = __pyx_t_42;
+5957: i += 1
__pyx_v_6shader_i = (__pyx_v_6shader_i + 1);
5958:
5959:
5960:
5961: @cython.binding(False)
5962: @cython.boundscheck(False)
5963: @cython.wraparound(False)
5964: @cython.nonecheck(False)
5965: @cython.cdivision(True)
+5966: cpdef inline void heatmap_convert(object surface_, bint rgb_=True):
static PyObject *__pyx_pw_6shader_147heatmap_convert(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_heatmap_convert(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_heatmap_convert *__pyx_optional_args) { int __pyx_v_rgb_ = ((int)1); CYTHON_UNUSED unsigned int __pyx_v_w; CYTHON_UNUSED unsigned int __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned int __pyx_v_s; int __pyx_v_i; CYTHON_UNUSED int __pyx_v_size; unsigned int __pyx_v_index; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; CYTHON_UNUSED short __pyx_v_bitsize; CYTHON_UNUSED short __pyx_v_bytesize; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatmap_convert", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_rgb_ = __pyx_optional_args->rgb_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.heatmap_convert", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array, 1); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_147heatmap_convert(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_146heatmap_convert[] = "\n TRANSFORM AN IMAGE INTO A HEATMAP EQUIVALENT\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param surface_ : pygame.Surface\n :param rgb_ : boolean; True transformed the image into a RGB heatmap model of False (BGR)\n :return : void\n "; static PyObject *__pyx_pw_6shader_147heatmap_convert(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_rgb_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatmap_convert (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_rgb,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 (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rgb); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "heatmap_convert") < 0)) __PYX_ERR(1, 5966, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_surface_ = values[0]; if (values[1]) { __pyx_v_rgb_ = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_rgb_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5966, __pyx_L3_error) } else { __pyx_v_rgb_ = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("heatmap_convert", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 5966, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.heatmap_convert", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_146heatmap_convert(__pyx_self, __pyx_v_surface_, __pyx_v_rgb_); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_146heatmap_convert(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_rgb_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("heatmap_convert", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1.__pyx_n = 1; __pyx_t_1.rgb_ = __pyx_v_rgb_; __pyx_f_6shader_heatmap_convert(__pyx_v_surface_, 0, &__pyx_t_1); __pyx_t_2 = __Pyx_void_to_None(NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("shader.heatmap_convert", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_heatmap_convert { int __pyx_n; int rgb_; };
5967: """
5968: TRANSFORM AN IMAGE INTO A HEATMAP EQUIVALENT
5969:
5970: Cython cpdef function, this function can be called directly and do not require a
5971: hook function.
5972:
5973: :param surface_ : pygame.Surface
5974: :param rgb_ : boolean; True transformed the image into a RGB heatmap model of False (BGR)
5975: :return : void
5976: """
5977:
5978: cdef:
5979: unsigned int w, h
+5980: w, h = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 5980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 5980, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 5980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 5980, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 5980, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5980, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_unsigned_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5980, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
5981:
5982: cdef:
+5983: unsigned char [::1] rgb_array = surface_.get_buffer()
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5983, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5983, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 5983, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rgb_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
5984: unsigned int s
5985: int i
+5986: int size = rgb_array.size
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_rgb_array, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5986, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5986, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 5986, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_size = __pyx_t_9;
+5987: unsigned int index = 0
__pyx_v_index = 0;
5988: unsigned char *r
5989: unsigned char *g
5990: unsigned char *b
+5991: short int bitsize = surface_.get_bitsize()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bitsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_3); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 5991, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bitsize = __pyx_t_10;
+5992: short int bytesize = surface_.get_bytesize()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bytesize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5992, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5992, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_3); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 5992, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bytesize = __pyx_t_10;
5993:
+5994: 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_L7; } __pyx_L6_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L7:; } }
5995: # RGB
+5996: if rgb_:
__pyx_t_11 = (__pyx_v_rgb_ != 0); if (__pyx_t_11) { /* … */ goto __pyx_L8; }
+5997: for i in prange(0, size, bytesize, schedule='static', num_threads=THREADS):
__pyx_t_9 = __pyx_v_size; __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_13 = (__pyx_t_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_13 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_13 = (__pyx_t_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_13 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_13; __pyx_t_12++){ { __pyx_v_i = (int)(0 + __pyx_t_10 * __pyx_t_12); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_index = ((unsigned int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_s = ((unsigned int)0xbad0bad0);
5998:
+5999: r = &rgb_array[i]
__pyx_t_14 = __pyx_v_i; __pyx_v_r = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_14)) ))));
+6000: g = &rgb_array[i + 1]
__pyx_t_14 = (__pyx_v_i + 1); __pyx_v_g = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_14)) ))));
+6001: b = &rgb_array[i + 2]
__pyx_t_14 = (__pyx_v_i + 2); __pyx_v_b = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_14)) ))));
6002:
+6003: s = r[0] + g[0] + b[0]
__pyx_v_s = (((__pyx_v_r[0]) + (__pyx_v_g[0])) + (__pyx_v_b[0]));
+6004: index = <int>(s * f_map)
__pyx_v_index = ((int)(__pyx_v_s * __pyx_v_6shader_f_map));
6005:
+6006: r[0] = <unsigned char>heatmap_array[index, 0]
if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("heatmap_array"); __PYX_ERR(1, 6006, __pyx_L11_error) } __pyx_t_15 = __pyx_v_index; __pyx_t_14 = 0; (__pyx_v_r[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_15 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_14)) ))));
+6007: g[0] = <unsigned char>heatmap_array[index, 1]
if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("heatmap_array"); __PYX_ERR(1, 6007, __pyx_L11_error) } __pyx_t_15 = __pyx_v_index; __pyx_t_14 = 1; (__pyx_v_g[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_15 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_14)) ))));
+6008: b[0] = <unsigned char>heatmap_array[index, 2]
if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("heatmap_array"); __PYX_ERR(1, 6008, __pyx_L11_error) } __pyx_t_15 = __pyx_v_index; __pyx_t_14 = 2; (__pyx_v_b[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_15 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_14)) )))); goto __pyx_L14; __pyx_L11_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L13; __pyx_L13:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates3) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_b; __pyx_parallel_temp1 = __pyx_v_g; __pyx_parallel_temp2 = __pyx_v_i; __pyx_parallel_temp3 = __pyx_v_index; __pyx_parallel_temp4 = __pyx_v_r; __pyx_parallel_temp5 = __pyx_v_s; } __pyx_L14:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_b = __pyx_parallel_temp0; __pyx_v_g = __pyx_parallel_temp1; __pyx_v_i = __pyx_parallel_temp2; __pyx_v_index = __pyx_parallel_temp3; __pyx_v_r = __pyx_parallel_temp4; __pyx_v_s = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L6_error; } } } #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
6009: # BGR
6010: else:
+6011: for i in prange(0, size, bytesize, schedule='static', num_threads=THREADS):
/*else*/ { __pyx_t_9 = __pyx_v_size; __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13++){ { __pyx_v_i = (int)(0 + __pyx_t_10 * __pyx_t_13); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_index = ((unsigned int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_s = ((unsigned int)0xbad0bad0);
6012:
+6013: r = &rgb_array[i]
__pyx_t_14 = __pyx_v_i; __pyx_v_r = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_14)) ))));
+6014: g = &rgb_array[i + 1]
__pyx_t_14 = (__pyx_v_i + 1); __pyx_v_g = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_14)) ))));
+6015: b = &rgb_array[i + 2]
__pyx_t_14 = (__pyx_v_i + 2); __pyx_v_b = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_14)) ))));
6016:
+6017: s = r[0] + g[0] + b[0]
__pyx_v_s = (((__pyx_v_r[0]) + (__pyx_v_g[0])) + (__pyx_v_b[0]));
+6018: index = <int>(s * f_map)
__pyx_v_index = ((int)(__pyx_v_s * __pyx_v_6shader_f_map));
6019:
+6020: r[0] = <unsigned char>heatmap_array[index, 2]
if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("heatmap_array"); __PYX_ERR(1, 6020, __pyx_L17_error) } __pyx_t_15 = __pyx_v_index; __pyx_t_14 = 2; (__pyx_v_r[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_15 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_14)) ))));
+6021: g[0] = <unsigned char>heatmap_array[index, 1]
if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("heatmap_array"); __PYX_ERR(1, 6021, __pyx_L17_error) } __pyx_t_15 = __pyx_v_index; __pyx_t_14 = 1; (__pyx_v_g[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_15 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_14)) ))));
+6022: b[0] = <unsigned char>heatmap_array[index, 0]
if (unlikely(!__pyx_v_6shader_heatmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("heatmap_array"); __PYX_ERR(1, 6022, __pyx_L17_error) } __pyx_t_15 = __pyx_v_index; __pyx_t_14 = 0; (__pyx_v_b[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_heatmap_array.data + __pyx_t_15 * __pyx_v_6shader_heatmap_array.strides[0]) )) + __pyx_t_14)) )))); goto __pyx_L20; __pyx_L17_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L19; __pyx_L19:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates4) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_b; __pyx_parallel_temp1 = __pyx_v_g; __pyx_parallel_temp2 = __pyx_v_i; __pyx_parallel_temp3 = __pyx_v_index; __pyx_parallel_temp4 = __pyx_v_r; __pyx_parallel_temp5 = __pyx_v_s; } __pyx_L20:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_b = __pyx_parallel_temp0; __pyx_v_g = __pyx_parallel_temp1; __pyx_v_i = __pyx_parallel_temp2; __pyx_v_index = __pyx_parallel_temp3; __pyx_v_r = __pyx_parallel_temp4; __pyx_v_s = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L6_error; } } } #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 } __pyx_L8:; }
6023:
6024:
6025:
6026: @cython.binding(False)
6027: @cython.boundscheck(False)
6028: @cython.wraparound(False)
6029: @cython.nonecheck(False)
6030: @cython.cdivision(True)
+6031: cpdef tuple blue_map(int wavelength, float gamma=1.0):
static PyObject *__pyx_pw_6shader_149blue_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_blue_map(int __pyx_v_wavelength, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_blue_map *__pyx_optional_args) { float __pyx_v_gamma = ((float)1.0); struct rgb_color_int __pyx_v_rgb_c; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blue_map", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_gamma = __pyx_optional_args->gamma; } } /* … */ /* 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_AddTraceback("shader.blue_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_149blue_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_148blue_map[] = "\n RETURN AN RGB COLOR VALUE MATCHING A SPECIFIC WAVELENGTH\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param wavelength : integer; Wavelength\n :param gamma : float; Gamma value\n :return : tuple RGB values (0 ... 255)\n "; static PyObject *__pyx_pw_6shader_149blue_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_wavelength; float __pyx_v_gamma; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blue_map (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_wavelength,&__pyx_n_s_gamma,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_wavelength)) != 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_gamma); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blue_map") < 0)) __PYX_ERR(1, 6031, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_wavelength = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_wavelength == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6031, __pyx_L3_error) if (values[1]) { __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 6031, __pyx_L3_error) } else { __pyx_v_gamma = ((float)1.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("blue_map", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 6031, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.blue_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_148blue_map(__pyx_self, __pyx_v_wavelength, __pyx_v_gamma); 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_6shader_148blue_map(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_wavelength, float __pyx_v_gamma) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blue_map", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.gamma = __pyx_v_gamma; __pyx_t_1 = __pyx_f_6shader_blue_map(__pyx_v_wavelength, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6031, __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("shader.blue_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_blue_map { int __pyx_n; float gamma; };
6032: """
6033: RETURN AN RGB COLOR VALUE MATCHING A SPECIFIC WAVELENGTH
6034:
6035: Cython cpdef function, this function can be called directly and do not require a
6036: hook function.
6037:
6038: :param wavelength : integer; Wavelength
6039: :param gamma : float; Gamma value
6040: :return : tuple RGB values (0 ... 255)
6041: """
6042: cdef rgb_color_int rgb_c
+6043: rgb_c = wavelength_to_rgb(wavelength, gamma)
__pyx_v_rgb_c = wavelength_to_rgb(__pyx_v_wavelength, __pyx_v_gamma);
+6044: return rgb_c.r, rgb_c.g, rgb_c.b
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.r); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6044, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.g); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6044, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.b); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6044, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6044, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
6045:
+6046: i = 0
__pyx_v_6shader_i = 0;
+6047: BLUEMAP = [ blue_map(i, 1.0) for i in range(450, 495) ]
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); for (__pyx_t_7 = 0x1C2; __pyx_t_7 < 0x1EF; __pyx_t_7+=1) { __pyx_v_6shader_i = __pyx_t_7; __pyx_t_45.__pyx_n = 1; __pyx_t_45.gamma = 1.0; __pyx_t_32 = __pyx_f_6shader_blue_map(__pyx_v_6shader_i, 0, &__pyx_t_45); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_32))) __PYX_ERR(1, 6047, __pyx_L1_error) __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; } if (PyDict_SetItem(__pyx_d, __pyx_n_s_BLUEMAP, __pyx_t_2) < 0) __PYX_ERR(1, 6047, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6048:
+6049: cdef float f_bluemap = (<float>495.0 - <float>450.0 - <float>1.0) / (<float>255.0 * <float>3.0)
__pyx_v_6shader_f_bluemap = (((((float)495.0) - ((float)450.0)) - ((float)1.0)) / (((float)255.0) * ((float)3.0)));
6050:
+6051: cdef unsigned char[:, ::1] bluemap_array = numpy.zeros((495 - 450, 3), numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_tuple__57); __Pyx_GIVEREF(__pyx_tuple__57); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_tuple__57); __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_33); __pyx_t_33 = 0; __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_32, __pyx_t_2, NULL); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_39 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_unsigned_char(__pyx_t_33, PyBUF_WRITABLE); if (unlikely(!__pyx_t_39.memview)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_bluemap_array, 1); __pyx_v_6shader_bluemap_array = __pyx_t_39; __pyx_t_39.memview = NULL; __pyx_t_39.data = NULL; /* … */ __pyx_tuple__57 = PyTuple_Pack(2, __pyx_int_45, __pyx_int_3); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(1, 6051, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__57); __Pyx_GIVEREF(__pyx_tuple__57);
6052:
+6053: i = 0
__pyx_v_6shader_i = 0;
+6054: for t in BLUEMAP:
__Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_n_s_BLUEMAP); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); if (likely(PyList_CheckExact(__pyx_t_33)) || PyTuple_CheckExact(__pyx_t_33)) { __pyx_t_2 = __pyx_t_33; __Pyx_INCREF(__pyx_t_2); __pyx_t_40 = 0; __pyx_t_41 = NULL; } else { __pyx_t_40 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_33); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_41 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_41)) __PYX_ERR(1, 6054, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; for (;;) { if (likely(!__pyx_t_41)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_40 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_33 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_40); __Pyx_INCREF(__pyx_t_33); __pyx_t_40++; if (unlikely(0 < 0)) __PYX_ERR(1, 6054, __pyx_L1_error) #else __pyx_t_33 = PySequence_ITEM(__pyx_t_2, __pyx_t_40); __pyx_t_40++; if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); #endif } else { if (__pyx_t_40 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_33 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_40); __Pyx_INCREF(__pyx_t_33); __pyx_t_40++; if (unlikely(0 < 0)) __PYX_ERR(1, 6054, __pyx_L1_error) #else __pyx_t_33 = PySequence_ITEM(__pyx_t_2, __pyx_t_40); __pyx_t_40++; if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6054, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); #endif } } else { __pyx_t_33 = __pyx_t_41(__pyx_t_2); if (unlikely(!__pyx_t_33)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(1, 6054, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_33); } if (!(likely(PyTuple_CheckExact(__pyx_t_33))||((__pyx_t_33) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_33)->tp_name), 0))) __PYX_ERR(1, 6054, __pyx_L1_error) __Pyx_XGOTREF(__pyx_v_6shader_t); __Pyx_DECREF_SET(__pyx_v_6shader_t, ((PyObject*)__pyx_t_33)); __Pyx_GIVEREF(__pyx_t_33); __pyx_t_33 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6055: bluemap_array[i, 0] = t[0]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6055, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 0)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 6055, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_bluemap_array.memview)) { __Pyx_RaiseUnboundLocalError("bluemap_array"); __PYX_ERR(1, 6055, __pyx_L1_error) } __pyx_t_44 = __pyx_v_6shader_i; __pyx_t_43 = 0; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_bluemap_array.data + __pyx_t_44 * __pyx_v_6shader_bluemap_array.strides[0]) )) + __pyx_t_43)) )) = __pyx_t_42;
+6056: bluemap_array[i, 1] = t[1]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6056, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 1)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 6056, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_bluemap_array.memview)) { __Pyx_RaiseUnboundLocalError("bluemap_array"); __PYX_ERR(1, 6056, __pyx_L1_error) } __pyx_t_43 = __pyx_v_6shader_i; __pyx_t_44 = 1; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_bluemap_array.data + __pyx_t_43 * __pyx_v_6shader_bluemap_array.strides[0]) )) + __pyx_t_44)) )) = __pyx_t_42;
+6057: bluemap_array[i, 2] = t[2]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6057, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 2)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 6057, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_bluemap_array.memview)) { __Pyx_RaiseUnboundLocalError("bluemap_array"); __PYX_ERR(1, 6057, __pyx_L1_error) } __pyx_t_44 = __pyx_v_6shader_i; __pyx_t_43 = 2; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_bluemap_array.data + __pyx_t_44 * __pyx_v_6shader_bluemap_array.strides[0]) )) + __pyx_t_43)) )) = __pyx_t_42;
+6058: i += 1
__pyx_v_6shader_i = (__pyx_v_6shader_i + 1);
6059:
6060: @cython.binding(False)
6061: @cython.boundscheck(False)
6062: @cython.wraparound(False)
6063: @cython.nonecheck(False)
6064: @cython.cdivision(True)
+6065: cpdef inline void bluescale(object surface_):
static PyObject *__pyx_pw_6shader_151bluescale(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_bluescale(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { CYTHON_UNUSED unsigned int __pyx_v_w; CYTHON_UNUSED unsigned int __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned int __pyx_v_s; int __pyx_v_i; CYTHON_UNUSED int __pyx_v_size; unsigned int __pyx_v_index; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; CYTHON_UNUSED short __pyx_v_bitsize; CYTHON_UNUSED short __pyx_v_bytesize; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bluescale", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.bluescale", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array, 1); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_151bluescale(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_150bluescale[] = "\n MAP AN IMAGE INTO A BLUE EQUIVALENT FORMAT\n THIS ALGORITHM IS USING THE WAVELENGTH FROM 450-495 NM TO\n REPRESENT THE IMAGE IN BLUE SHADES\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param surface_ : pygame.Surface to transform\n :return : void\n "; static PyObject *__pyx_pw_6shader_151bluescale(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bluescale (wrapper)", 0); __pyx_r = __pyx_pf_6shader_150bluescale(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_150bluescale(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bluescale", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_bluescale(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6065, __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("shader.bluescale", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
6066: """
6067: MAP AN IMAGE INTO A BLUE EQUIVALENT FORMAT
6068: THIS ALGORITHM IS USING THE WAVELENGTH FROM 450-495 NM TO
6069: REPRESENT THE IMAGE IN BLUE SHADES
6070:
6071: Cython cpdef function, this function can be called directly and do not require a
6072: hook function.
6073:
6074: :param surface_ : pygame.Surface to transform
6075: :return : void
6076: """
6077:
6078:
6079: cdef:
6080: unsigned int w, h
+6081: w, h = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 6081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 6081, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 6081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 6081, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 6081, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6081, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_unsigned_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6081, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
6082:
6083: cdef:
+6084: unsigned char [::1] rgb_array = surface_.get_buffer()
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 6084, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rgb_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
6085: unsigned int s
6086: int i
+6087: int size = rgb_array.size
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_rgb_array, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6087, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_size = __pyx_t_9;
+6088: unsigned int index = 0
__pyx_v_index = 0;
6089: unsigned char *r
6090: unsigned char *g
6091: unsigned char *b
+6092: short int bitsize = surface_.get_bitsize()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bitsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_3); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 6092, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bitsize = __pyx_t_10;
+6093: short int bytesize = surface_.get_bytesize()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bytesize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_3); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 6093, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bytesize = __pyx_t_10;
6094:
+6095: 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_L7; } __pyx_L6_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L7:; } }
+6096: for i in prange(0, size, bytesize, schedule='static', num_threads=THREADS):
__pyx_t_9 = __pyx_v_size; __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){ { __pyx_v_i = (int)(0 + __pyx_t_10 * __pyx_t_11); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_index = ((unsigned int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_s = ((unsigned int)0xbad0bad0);
6097:
+6098: r = &rgb_array[i]
__pyx_t_13 = __pyx_v_i; __pyx_v_r = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_13)) ))));
+6099: g = &rgb_array[i + 1]
__pyx_t_13 = (__pyx_v_i + 1); __pyx_v_g = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_13)) ))));
+6100: b = &rgb_array[i + 2]
__pyx_t_13 = (__pyx_v_i + 2); __pyx_v_b = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_13)) ))));
6101:
+6102: s = r[0] + g[0] + b[0]
__pyx_v_s = (((__pyx_v_r[0]) + (__pyx_v_g[0])) + (__pyx_v_b[0]));
+6103: index = <int>(s * f_bluemap)
__pyx_v_index = ((int)(__pyx_v_s * __pyx_v_6shader_f_bluemap));
6104:
+6105: r[0] = <unsigned char>bluemap_array[index, 2]
if (unlikely(!__pyx_v_6shader_bluemap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("bluemap_array"); __PYX_ERR(1, 6105, __pyx_L10_error) } __pyx_t_14 = __pyx_v_index; __pyx_t_13 = 2; (__pyx_v_r[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_bluemap_array.data + __pyx_t_14 * __pyx_v_6shader_bluemap_array.strides[0]) )) + __pyx_t_13)) ))));
+6106: g[0] = <unsigned char>bluemap_array[index, 1]
if (unlikely(!__pyx_v_6shader_bluemap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("bluemap_array"); __PYX_ERR(1, 6106, __pyx_L10_error) } __pyx_t_14 = __pyx_v_index; __pyx_t_13 = 1; (__pyx_v_g[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_bluemap_array.data + __pyx_t_14 * __pyx_v_6shader_bluemap_array.strides[0]) )) + __pyx_t_13)) ))));
+6107: b[0] = <unsigned char>bluemap_array[index, 0]
if (unlikely(!__pyx_v_6shader_bluemap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("bluemap_array"); __PYX_ERR(1, 6107, __pyx_L10_error) } __pyx_t_14 = __pyx_v_index; __pyx_t_13 = 0; (__pyx_v_b[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_bluemap_array.data + __pyx_t_14 * __pyx_v_6shader_bluemap_array.strides[0]) )) + __pyx_t_13)) )))); goto __pyx_L13; __pyx_L10_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L12; __pyx_L12:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates5) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_b; __pyx_parallel_temp1 = __pyx_v_g; __pyx_parallel_temp2 = __pyx_v_i; __pyx_parallel_temp3 = __pyx_v_index; __pyx_parallel_temp4 = __pyx_v_r; __pyx_parallel_temp5 = __pyx_v_s; } __pyx_L13:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_b = __pyx_parallel_temp0; __pyx_v_g = __pyx_parallel_temp1; __pyx_v_i = __pyx_parallel_temp2; __pyx_v_index = __pyx_parallel_temp3; __pyx_v_r = __pyx_parallel_temp4; __pyx_v_s = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L6_error; } } } #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 }
6108:
6109:
6110:
6111: @cython.binding(False)
6112: @cython.boundscheck(False)
6113: @cython.wraparound(False)
6114: @cython.nonecheck(False)
6115: @cython.cdivision(True)
+6116: cpdef tuple red_map(int wavelength, float gamma=1.0):
static PyObject *__pyx_pw_6shader_153red_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_red_map(int __pyx_v_wavelength, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_red_map *__pyx_optional_args) { float __pyx_v_gamma = ((float)1.0); struct rgb_color_int __pyx_v_rgb_c; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("red_map", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_gamma = __pyx_optional_args->gamma; } } /* … */ /* 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_AddTraceback("shader.red_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_153red_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_152red_map[] = "\n RETURN AN RGB COLOR VALUE MATCHING A SPECIFIC WAVELENGTH\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param wavelength : integer; Wavelength\n :param gamma : float; Gamma value\n :return : tuple RGB values (0 ... 255)\n "; static PyObject *__pyx_pw_6shader_153red_map(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_wavelength; float __pyx_v_gamma; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("red_map (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_wavelength,&__pyx_n_s_gamma,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_wavelength)) != 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_gamma); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "red_map") < 0)) __PYX_ERR(1, 6116, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { 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_wavelength = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_wavelength == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6116, __pyx_L3_error) if (values[1]) { __pyx_v_gamma = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_gamma == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 6116, __pyx_L3_error) } else { __pyx_v_gamma = ((float)1.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("red_map", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 6116, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.red_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_152red_map(__pyx_self, __pyx_v_wavelength, __pyx_v_gamma); 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_6shader_152red_map(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_wavelength, float __pyx_v_gamma) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("red_map", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.gamma = __pyx_v_gamma; __pyx_t_1 = __pyx_f_6shader_red_map(__pyx_v_wavelength, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6116, __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("shader.red_map", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_red_map { int __pyx_n; float gamma; };
6117: """
6118: RETURN AN RGB COLOR VALUE MATCHING A SPECIFIC WAVELENGTH
6119:
6120: Cython cpdef function, this function can be called directly and do not require a
6121: hook function.
6122:
6123: :param wavelength : integer; Wavelength
6124: :param gamma : float; Gamma value
6125: :return : tuple RGB values (0 ... 255)
6126: """
6127: cdef rgb_color_int rgb_c
+6128: rgb_c = wavelength_to_rgb(wavelength, gamma)
__pyx_v_rgb_c = wavelength_to_rgb(__pyx_v_wavelength, __pyx_v_gamma);
+6129: return rgb_c.r, rgb_c.g, rgb_c.b
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.r); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.g); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rgb_c.b); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
6130:
+6131: i = 0
__pyx_v_6shader_i = 0;
+6132: REDMAP = [ red_map(i, 1.0) for i in range(620, 750) ]
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); for (__pyx_t_7 = 0x26C; __pyx_t_7 < 0x2EE; __pyx_t_7+=1) { __pyx_v_6shader_i = __pyx_t_7; __pyx_t_46.__pyx_n = 1; __pyx_t_46.gamma = 1.0; __pyx_t_33 = __pyx_f_6shader_red_map(__pyx_v_6shader_i, 0, &__pyx_t_46); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_33))) __PYX_ERR(1, 6132, __pyx_L1_error) __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; } if (PyDict_SetItem(__pyx_d, __pyx_n_s_REDMAP, __pyx_t_2) < 0) __PYX_ERR(1, 6132, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6133:
+6134: cdef float f_redmap = (<float>750.0 - <float>620.0 - <float>1.0) / (<float>255.0 * <float>3.0)
__pyx_v_6shader_f_redmap = (((((float)750.0) - ((float)620.0)) - ((float)1.0)) / (((float)255.0) * ((float)3.0)));
6135:
+6136: cdef unsigned char[:, ::1] redmap_array = numpy.zeros((750 - 620, 3), numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_tuple__58); __Pyx_GIVEREF(__pyx_tuple__58); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_tuple__58); __Pyx_GIVEREF(__pyx_t_32); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_32); __pyx_t_32 = 0; __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_33, __pyx_t_2, NULL); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_39 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_unsigned_char(__pyx_t_32, PyBUF_WRITABLE); if (unlikely(!__pyx_t_39.memview)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_redmap_array, 1); __pyx_v_6shader_redmap_array = __pyx_t_39; __pyx_t_39.memview = NULL; __pyx_t_39.data = NULL; /* … */ __pyx_tuple__58 = PyTuple_Pack(2, __pyx_int_130, __pyx_int_3); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(1, 6136, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__58); __Pyx_GIVEREF(__pyx_tuple__58);
6137:
+6138: i = 0
__pyx_v_6shader_i = 0;
+6139: for t in REDMAP:
__Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_n_s_REDMAP); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); if (likely(PyList_CheckExact(__pyx_t_32)) || PyTuple_CheckExact(__pyx_t_32)) { __pyx_t_2 = __pyx_t_32; __Pyx_INCREF(__pyx_t_2); __pyx_t_40 = 0; __pyx_t_41 = NULL; } else { __pyx_t_40 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_41 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_41)) __PYX_ERR(1, 6139, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; for (;;) { if (likely(!__pyx_t_41)) { if (likely(PyList_CheckExact(__pyx_t_2))) { if (__pyx_t_40 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_32 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_40); __Pyx_INCREF(__pyx_t_32); __pyx_t_40++; if (unlikely(0 < 0)) __PYX_ERR(1, 6139, __pyx_L1_error) #else __pyx_t_32 = PySequence_ITEM(__pyx_t_2, __pyx_t_40); __pyx_t_40++; if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); #endif } else { if (__pyx_t_40 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_32 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_40); __Pyx_INCREF(__pyx_t_32); __pyx_t_40++; if (unlikely(0 < 0)) __PYX_ERR(1, 6139, __pyx_L1_error) #else __pyx_t_32 = PySequence_ITEM(__pyx_t_2, __pyx_t_40); __pyx_t_40++; if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 6139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); #endif } } else { __pyx_t_32 = __pyx_t_41(__pyx_t_2); if (unlikely(!__pyx_t_32)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(1, 6139, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_32); } if (!(likely(PyTuple_CheckExact(__pyx_t_32))||((__pyx_t_32) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_32)->tp_name), 0))) __PYX_ERR(1, 6139, __pyx_L1_error) __Pyx_XGOTREF(__pyx_v_6shader_t); __Pyx_DECREF_SET(__pyx_v_6shader_t, ((PyObject*)__pyx_t_32)); __Pyx_GIVEREF(__pyx_t_32); __pyx_t_32 = 0; /* … */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6140: redmap_array[i, 0] = t[0]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6140, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 0)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 6140, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundLocalError("redmap_array"); __PYX_ERR(1, 6140, __pyx_L1_error) } __pyx_t_43 = __pyx_v_6shader_i; __pyx_t_44 = 0; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_43 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_44)) )) = __pyx_t_42;
+6141: redmap_array[i, 1] = t[1]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6141, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 1)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 6141, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundLocalError("redmap_array"); __PYX_ERR(1, 6141, __pyx_L1_error) } __pyx_t_44 = __pyx_v_6shader_i; __pyx_t_43 = 1; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_44 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_43)) )) = __pyx_t_42;
+6142: redmap_array[i, 2] = t[2]
if (unlikely(__pyx_v_6shader_t == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6142, __pyx_L1_error) } __pyx_t_42 = __Pyx_PyInt_As_unsigned_char(PyTuple_GET_ITEM(__pyx_v_6shader_t, 2)); if (unlikely((__pyx_t_42 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(1, 6142, __pyx_L1_error) if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundLocalError("redmap_array"); __PYX_ERR(1, 6142, __pyx_L1_error) } __pyx_t_43 = __pyx_v_6shader_i; __pyx_t_44 = 2; *((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_43 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_44)) )) = __pyx_t_42;
+6143: i += 1
__pyx_v_6shader_i = (__pyx_v_6shader_i + 1);
6144:
6145:
6146:
6147: @cython.binding(False)
6148: @cython.boundscheck(False)
6149: @cython.wraparound(False)
6150: @cython.nonecheck(False)
6151: @cython.cdivision(True)
+6152: cpdef inline void redscale(object surface_):
static PyObject *__pyx_pw_6shader_155redscale(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static CYTHON_INLINE void __pyx_f_6shader_redscale(PyObject *__pyx_v_surface_, CYTHON_UNUSED int __pyx_skip_dispatch) { CYTHON_UNUSED unsigned int __pyx_v_w; CYTHON_UNUSED unsigned int __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned int __pyx_v_s; int __pyx_v_i; CYTHON_UNUSED int __pyx_v_size; unsigned int __pyx_v_index; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; CYTHON_UNUSED short __pyx_v_bitsize; CYTHON_UNUSED short __pyx_v_bytesize; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("redscale", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_WriteUnraisable("shader.redscale", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array, 1); __Pyx_RefNannyFinishContext(); } /* Python wrapper */ static PyObject *__pyx_pw_6shader_155redscale(PyObject *__pyx_self, PyObject *__pyx_v_surface_); /*proto*/ static char __pyx_doc_6shader_154redscale[] = "\n MAP AN IMAGE INTO A RED EQUIVALENT FORMAT\n THIS ALGORITHM IS USING THE WAVELENGTH FROM 620 TO 750 NM TO\n REPRESENT THE IMAGE IN RED SHADES\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param surface_ : pygame.Surface to transform\n :return : void\n "; static PyObject *__pyx_pw_6shader_155redscale(PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("redscale (wrapper)", 0); __pyx_r = __pyx_pf_6shader_154redscale(__pyx_self, ((PyObject *)__pyx_v_surface_)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6shader_154redscale(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("redscale", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_void_to_None(__pyx_f_6shader_redscale(__pyx_v_surface_, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6152, __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("shader.redscale", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
6153: """
6154: MAP AN IMAGE INTO A RED EQUIVALENT FORMAT
6155: THIS ALGORITHM IS USING THE WAVELENGTH FROM 620 TO 750 NM TO
6156: REPRESENT THE IMAGE IN RED SHADES
6157:
6158: Cython cpdef function, this function can be called directly and do not require a
6159: hook function.
6160:
6161: :param surface_ : pygame.Surface to transform
6162: :return : void
6163: """
6164:
6165:
6166: cdef:
6167: unsigned int w, h
+6168: w, h = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 6168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 6168, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 6168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 6168, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 6168, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyInt_As_unsigned_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_unsigned_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_w = __pyx_t_6; __pyx_v_h = __pyx_t_7;
6169:
6170: cdef:
+6171: unsigned char [::1] rgb_array = surface_.get_buffer()
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 6171, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_rgb_array = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
6172: unsigned int s
6173: int i
+6174: int size = rgb_array.size
__pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_rgb_array, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6174, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_size = __pyx_t_9;
+6175: unsigned int index = 0
__pyx_v_index = 0;
6176: unsigned char *r
6177: unsigned char *g
6178: unsigned char *b
+6179: short int bitsize = surface_.get_bitsize()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bitsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_3); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 6179, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bitsize = __pyx_t_10;
+6180: short int bytesize = surface_.get_bytesize()
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_bytesize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyInt_As_short(__pyx_t_3); if (unlikely((__pyx_t_10 == (short)-1) && PyErr_Occurred())) __PYX_ERR(1, 6180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bytesize = __pyx_t_10;
6181:
+6182: 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_L7; } __pyx_L6_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L7:; } }
+6183: for i in prange(0, size, bytesize, schedule='static', num_threads=THREADS):
__pyx_t_9 = __pyx_v_size; __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) __pyx_t_10 = __pyx_v_bytesize; if ((__pyx_t_10 == 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_9 - 0 + __pyx_t_10 - __pyx_t_10/abs(__pyx_t_10)) / __pyx_t_10; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) lastprivate(__pyx_v_r) lastprivate(__pyx_v_s) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){ { __pyx_v_i = (int)(0 + __pyx_t_10 * __pyx_t_11); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_index = ((unsigned int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_s = ((unsigned int)0xbad0bad0);
6184:
+6185: r = &rgb_array[i]
__pyx_t_13 = __pyx_v_i; __pyx_v_r = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_13)) ))));
+6186: g = &rgb_array[i + 1]
__pyx_t_13 = (__pyx_v_i + 1); __pyx_v_g = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_13)) ))));
+6187: b = &rgb_array[i + 2]
__pyx_t_13 = (__pyx_v_i + 2); __pyx_v_b = (&(*((unsigned char *) ( /* dim=0 */ ((char *) (((unsigned char *) __pyx_v_rgb_array.data) + __pyx_t_13)) ))));
6188:
+6189: s = r[0] + g[0] + b[0]
__pyx_v_s = (((__pyx_v_r[0]) + (__pyx_v_g[0])) + (__pyx_v_b[0]));
+6190: index = <int>(s * f_redmap)
__pyx_v_index = ((int)(__pyx_v_s * __pyx_v_6shader_f_redmap));
6191:
+6192: r[0] = <unsigned char>redmap_array[index, 2]
if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("redmap_array"); __PYX_ERR(1, 6192, __pyx_L10_error) } __pyx_t_14 = __pyx_v_index; __pyx_t_13 = 2; (__pyx_v_r[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_14 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_13)) ))));
+6193: g[0] = <unsigned char>redmap_array[index, 1]
if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("redmap_array"); __PYX_ERR(1, 6193, __pyx_L10_error) } __pyx_t_14 = __pyx_v_index; __pyx_t_13 = 1; (__pyx_v_g[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_14 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_13)) ))));
+6194: b[0] = <unsigned char>redmap_array[index, 0]
if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("redmap_array"); __PYX_ERR(1, 6194, __pyx_L10_error) } __pyx_t_14 = __pyx_v_index; __pyx_t_13 = 0; (__pyx_v_b[0]) = ((unsigned char)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_14 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_13)) )))); goto __pyx_L13; __pyx_L10_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L12; __pyx_L12:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates6) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_b; __pyx_parallel_temp1 = __pyx_v_g; __pyx_parallel_temp2 = __pyx_v_i; __pyx_parallel_temp3 = __pyx_v_index; __pyx_parallel_temp4 = __pyx_v_r; __pyx_parallel_temp5 = __pyx_v_s; } __pyx_L13:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_b = __pyx_parallel_temp0; __pyx_v_g = __pyx_parallel_temp1; __pyx_v_i = __pyx_parallel_temp2; __pyx_v_index = __pyx_parallel_temp3; __pyx_v_r = __pyx_parallel_temp4; __pyx_v_s = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L6_error; } } } #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 }
6195:
6196:
6197:
6198: @cython.binding(False)
6199: @cython.boundscheck(False)
6200: @cython.wraparound(False)
6201: @cython.nonecheck(False)
6202: @cython.cdivision(True)
+6203: cdef inline void shader_blood_inplace_c(
static CYTHON_INLINE void __pyx_f_6shader_shader_blood_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_, __Pyx_memviewslice __pyx_v_mask_, float __pyx_v_perc_) { int __pyx_v_w; CYTHON_UNUSED int __pyx_v_h; CYTHON_UNUSED int __pyx_v_bytesize; int __pyx_v_i; int __pyx_v_j; unsigned int __pyx_v_index; unsigned char *__pyx_v_r; float __pyx_v_theta; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_blood_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_WriteUnraisable("shader.shader_blood_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
6204: unsigned char [:, :, :] rgb_array_, float [:, :] mask_, float perc_):
6205:
6206: """
6207: SHADER HURT EFFECT
6208: THE MASK DETERMINE THE CONTOUR USED FOR THE BLOOD EFFECT.
6209:
6210: The Array (rgb_array) must be a numpy array shape (w, h, 3)
6211: containing RGB pixels, please refer to pygame
6212: function pixels3d or array3d to convert an image into a
6213: 3d array (library surfarray)
6214:
6215: :param rgb_array_ : numpy.ndarray shape (w, h, 3) of unsigned
6216: char representing the surface pixels
6217: :param mask_ : numpy.ndarray shape (w, h) of float values in range [0.0...1.0]
6218: :param perc_ : Percentage value in range [0.0 ... 1.0] with 1.0 being 100%
6219:
6220: :return: void
6221: """
+6222: assert 0.0 <= perc_ <= 1.0, "perc_ variable must be in range[0.0 ... 1.0] got %s " % perc_
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_1 = (0.0 <= __pyx_v_perc_); if (__pyx_t_1) { __pyx_t_1 = (__pyx_v_perc_ <= 1.0); } if (unlikely(!(__pyx_t_1 != 0))) { __pyx_t_2 = PyFloat_FromDouble(__pyx_v_perc_); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_perc__variable_must_be_in_range, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(1, 6222, __pyx_L1_error) } } #endif
6223:
6224: cdef:
6225: int w, h, bytesize
+6226: w, h, bytesize = (<object> rgb_array_).shape
__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; 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(1, 6226, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); __pyx_t_5 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 2; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(1, 6226, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 6226, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_w = __pyx_t_8; __pyx_v_h = __pyx_t_9; __pyx_v_bytesize = __pyx_t_10;
6227:
6228: cdef:
6229: unsigned int s
6230: int i, j
+6231: unsigned int index = 0
__pyx_v_index = 0;
6232: unsigned char *r
6233: unsigned char *g
6234: unsigned char *b
6235: float theta
6236:
6237:
+6238: 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_L7; } __pyx_L6_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L7:; } }
+6239: for j in prange(0, h, schedule='static', num_threads=THREADS):
__pyx_t_10 = __pyx_v_h; 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 lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_theta) schedule(static) /* … */ __pyx_t_10 = __pyx_v_h; 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 lastprivate(__pyx_v_i) lastprivate(__pyx_v_index) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_theta) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_12; __pyx_t_11++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_11); /* Initialize private variables to invalid values */ __pyx_v_i = ((int)0xbad0bad0); __pyx_v_index = ((unsigned int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_theta = ((float)__PYX_NAN());
+6240: for i in range(0, w):
__pyx_t_9 = __pyx_v_w; __pyx_t_8 = __pyx_t_9; for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_8; __pyx_t_13+=1) { __pyx_v_i = __pyx_t_13;
6241:
+6242: r = &rgb_array_[i, j, 0]
__pyx_t_14 = __pyx_v_i; __pyx_t_15 = __pyx_v_j; __pyx_t_16 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_14 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) ))));
6243: # g = &rgb_array_[i, j, 1]
6244: # b = &rgb_array_[i, j, 2]
6245:
6246: # s = r[0] + g[0] + b[0]
6247: # index = <int>(s * f_redmap)
6248:
+6249: index = <int>(r[0] * f_redmap)
__pyx_v_index = ((int)((__pyx_v_r[0]) * __pyx_v_6shader_f_redmap));
+6250: theta = <float>(mask_[i, j] * perc_)
__pyx_t_16 = __pyx_v_i; __pyx_t_15 = __pyx_v_j; __pyx_v_theta = ((float)((*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_mask_.data + __pyx_t_16 * __pyx_v_mask_.strides[0]) ) + __pyx_t_15 * __pyx_v_mask_.strides[1]) ))) * __pyx_v_perc_));
6251:
6252: # BEST METHOD (SLOW)
6253: # r[0] = <unsigned char> (r[0] * (1.0 - theta) +
6254: # <float>redmap_array[index, 0] * theta)
6255: # g[0] = <unsigned char> (g[0] * (1.0 - theta) +
6256: # <float>redmap_array[index, 1] * theta)
6257: # b[0] = <unsigned char> (b[0] * (1.0 - theta) +
6258: # <float>redmap_array[index, 2] * theta)
6259:
6260: # ALTERNATIVE WITH BEST PERFORMANCES
+6261: r[0] = <unsigned char> (
(__pyx_v_r[0]) = ((unsigned char)__pyx_t_20); } goto __pyx_L15; __pyx_L10_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L14; __pyx_L14:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates7) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_i; __pyx_parallel_temp1 = __pyx_v_index; __pyx_parallel_temp2 = __pyx_v_j; __pyx_parallel_temp3 = __pyx_v_r; __pyx_parallel_temp4 = __pyx_v_theta; } __pyx_L15:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_i = __pyx_parallel_temp0; __pyx_v_index = __pyx_parallel_temp1; __pyx_v_j = __pyx_parallel_temp2; __pyx_v_r = __pyx_parallel_temp3; __pyx_v_theta = __pyx_parallel_temp4; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L6_error; } } } #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 }
+6262: min(r[0] + <float> redmap_array[index, 0] * theta, <unsigned char>255))
__pyx_t_17 = ((unsigned char)0xFF); if (unlikely(!__pyx_v_6shader_redmap_array.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("redmap_array"); __PYX_ERR(1, 6262, __pyx_L10_error) } __pyx_t_18 = __pyx_v_index; __pyx_t_15 = 0; __pyx_t_19 = ((__pyx_v_r[0]) + (((float)(*((unsigned char *) ( /* dim=1 */ ((char *) (((unsigned char *) ( /* dim=0 */ (__pyx_v_6shader_redmap_array.data + __pyx_t_18 * __pyx_v_6shader_redmap_array.strides[0]) )) + __pyx_t_15)) )))) * __pyx_v_theta)); if (((__pyx_t_17 < __pyx_t_19) != 0)) { __pyx_t_20 = __pyx_t_17; } else { __pyx_t_20 = __pyx_t_19; }
6263:
6264:
6265:
6266: #
6267: # def interpolant(t):
6268: # return t*t*t*(t*(t*6 - 15) + 10)
6269: #
6270: #
6271: # def generate_perlin_noise_2d(
6272: # shape, res, tileable=(False, False), interpolant=interpolant
6273: # ):
6274: # """Generate a 2D numpy array of perlin noise.
6275: #
6276: # Args:
6277: # shape: The shape of the generated array (tuple of two ints).
6278: # This must be a multple of res.
6279: # res: The number of periods of noise to generate along each
6280: # axis (tuple of two ints). Note shape must be a multiple of
6281: # res.
6282: # tileable: If the noise should be tileable along each axis
6283: # (tuple of two bools). Defaults to (False, False).
6284: # interpolant: The interpolation function, defaults to
6285: # t*t*t*(t*(t*6 - 15) + 10).
6286: #
6287: # Returns:
6288: # A numpy array of shape shape with the generated noise.
6289: #
6290: # Raises:
6291: # ValueError: If shape is not a multiple of res.
6292: # """
6293: # delta = (res[0] / shape[0], res[1] / shape[1])
6294: # d = (shape[0] // res[0], shape[1] // res[1])
6295: # grid = numpy.mgrid[0:res[0]:delta[0], 0:res[1]:delta[1]]\
6296: # .transpose(1, 2, 0) % 1
6297: # # Gradients
6298: # angles = 2*numpy.pi*numpy.random.rand(res[0]+1, res[1]+1)
6299: # gradients = numpy.dstack((numpy.cos(angles), numpy.sin(angles)))
6300: # if tileable[0]:
6301: # gradients[-1,:] = gradients[0,:]
6302: # if tileable[1]:
6303: # gradients[:,-1] = gradients[:,0]
6304: # gradients = gradients.repeat(d[0], 0).repeat(d[1], 1)
6305: # g00 = gradients[ :-d[0], :-d[1]]
6306: # g10 = gradients[d[0]: , :-d[1]]
6307: # g01 = gradients[ :-d[0],d[1]: ]
6308: # g11 = gradients[d[0]: ,d[1]: ]
6309: # # Ramps
6310: # n00 = numpy.sum(numpy.dstack((grid[:,:,0] , grid[:,:,1] )) * g00, 2)
6311: # n10 = numpy.sum(numpy.dstack((grid[:,:,0]-1, grid[:,:,1] )) * g10, 2)
6312: # n01 = numpy.sum(numpy.dstack((grid[:,:,0] , grid[:,:,1]-1)) * g01, 2)
6313: # n11 = numpy.sum(numpy.dstack((grid[:,:,0]-1, grid[:,:,1]-1)) * g11, 2)
6314: # # Interpolation
6315: # t = interpolant(grid)
6316: # n0 = n00*(1-t[:,:,0]) + t[:,:,0]*n10
6317: # n1 = n01*(1-t[:,:,0]) + t[:,:,0]*n11
6318: # return numpy.sqrt(2)*((1-t[:,:,1])*n0 + t[:,:,1]*n1)
6319: #
6320: #
6321: #
6322: # @cython.boundscheck(False)
6323: # @cython.wraparound(False)
6324: # @cython.nonecheck(False)
6325: # @cython.cdivision(True)
6326: # cdef inline cloud_effect_inplace_c(int frame):
6327: #
6328: # cdef int w, h, i, j
6329: #
6330: # # cdef float [:, :] noise_array = generate_perlin_noise_2d(
6331: # (800, 800), (16, 16), tileable=(True, True))
6332: #
6333: # cdef float [:, :] noise_array = numpy.empty((200, 200), float32)
6334: #
6335: # for j in range(0, 200):
6336: # for i in range(0, 200):
6337: # noise_array[i, j] = noise.pnoise2((i+ 50 * cos(frame * M_PI/180.0))/ 8.0,
6338: # j / 8.0,
6339: # octaves=8,
6340: # persistence=0.25,
6341: # lacunarity=2,
6342: # repeatx=1024,
6343: # repeaty=1024,
6344: # base=0)
6345: #
6346: #
6347: # cdef:
6348: # unsigned char [:, :, :] dest_array = numpy.empty((800, 800, 3), numpy.uint8)
6349: # int ii, jj
6350: # int v
6351: #
6352: # with nogil:
6353: # for i in prange(0, 800, schedule='static', num_threads=THREADS):
6354: # for j in range(0, 800):
6355: # ii = <int>(200.0/800.0 * i)
6356: # jj = <int>(200.0/800.0 * j)
6357: # dest_array[i, j, 0] =<unsigned char>(noise_array[ii, jj] * 255)
6358: # dest_array[i, j, 1] =<unsigned char>(noise_array[ii, jj] * 255)
6359: # dest_array[i, j, 2] =<unsigned char>(noise_array[ii, jj] * 255)
6360: #
6361: #
6362: # return pygame.surfarray.make_surface(asarray(dest_array))
6363: #
6364:
6365:
6366: @cython.boundscheck(False)
6367: @cython.wraparound(False)
6368: @cython.nonecheck(False)
6369: @cython.cdivision(True)
+6370: cpdef inline unsigned int rgb_to_int(int red, int green, int blue)nogil:
static PyObject *__pyx_pw_6shader_157rgb_to_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE unsigned int __pyx_f_6shader_rgb_to_int(int __pyx_v_red, int __pyx_v_green, int __pyx_v_blue, CYTHON_UNUSED int __pyx_skip_dispatch) { unsigned int __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_157rgb_to_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_156rgb_to_int[] = "\n CONVERT RGB MODEL INTO A PYTHON INTEGER EQUIVALENT TO THE FUNCTION PYGAME MAP_RGB()\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param red : Red color value, must be in range [0..255]\n :param green : Green color value, must be in range [0..255]\n :param blue : Blue color, must be in range [0.255]\n :return : returns a positive python integer representing the RGB values(int32)\n "; static PyObject *__pyx_pw_6shader_157rgb_to_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_red; int __pyx_v_green; int __pyx_v_blue; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_int (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_red,&__pyx_n_s_green,&__pyx_n_s_blue,0}; PyObject* values[3] = {0,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 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_red)) != 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_green)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rgb_to_int", 1, 3, 3, 1); __PYX_ERR(1, 6370, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_blue)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("rgb_to_int", 1, 3, 3, 2); __PYX_ERR(1, 6370, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "rgb_to_int") < 0)) __PYX_ERR(1, 6370, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_red = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_red == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6370, __pyx_L3_error) __pyx_v_green = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_green == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6370, __pyx_L3_error) __pyx_v_blue = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_blue == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6370, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rgb_to_int", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 6370, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.rgb_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_156rgb_to_int(__pyx_self, __pyx_v_red, __pyx_v_green, __pyx_v_blue); 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_6shader_156rgb_to_int(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_red, int __pyx_v_green, int __pyx_v_blue) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rgb_to_int", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_f_6shader_rgb_to_int(__pyx_v_red, __pyx_v_green, __pyx_v_blue, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6370, __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("shader.rgb_to_int", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
6371: """
6372: CONVERT RGB MODEL INTO A PYTHON INTEGER EQUIVALENT TO THE FUNCTION PYGAME MAP_RGB()
6373:
6374: Cython cpdef function, this function can be called directly and do not require a
6375: hook function.
6376:
6377: :param red : Red color value, must be in range [0..255]
6378: :param green : Green color value, must be in range [0..255]
6379: :param blue : Blue color, must be in range [0.255]
6380: :return : returns a positive python integer representing the RGB values(int32)
6381: """
+6382: return 65536 * red + 256 * green + blue
__pyx_r = (((0x10000 * __pyx_v_red) + (0x100 * __pyx_v_green)) + __pyx_v_blue); goto __pyx_L0;
6383:
6384: @cython.boundscheck(False)
6385: @cython.wraparound(False)
6386: @cython.nonecheck(False)
6387: @cython.cdivision(True)
+6388: cpdef inline rgb int_to_rgb(unsigned int n)nogil:
static PyObject *__pyx_pw_6shader_159int_to_rgb(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/ static CYTHON_INLINE struct rgb __pyx_f_6shader_int_to_rgb(unsigned int __pyx_v_n, CYTHON_UNUSED int __pyx_skip_dispatch) { struct rgb __pyx_v_rgb_; struct rgb __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_159int_to_rgb(PyObject *__pyx_self, PyObject *__pyx_arg_n); /*proto*/ static char __pyx_doc_6shader_158int_to_rgb[] = "\n CONVERT A PYTHON INTEGER INTO A RGB COLOUR MODEL (UNSIGNED CHAR VALUES [0..255]).\n EQUIVALENT TO PYGAME UNMAP_RGB()\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n :param n : positive integer value to convert\n :return : return a C structure rgb containing RGB values\n "; static PyObject *__pyx_pw_6shader_159int_to_rgb(PyObject *__pyx_self, PyObject *__pyx_arg_n) { unsigned int __pyx_v_n; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("int_to_rgb (wrapper)", 0); assert(__pyx_arg_n); { __pyx_v_n = __Pyx_PyInt_As_unsigned_int(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6388, __pyx_L3_error) } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; __Pyx_AddTraceback("shader.int_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_158int_to_rgb(__pyx_self, ((unsigned int)__pyx_v_n)); 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_6shader_158int_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, unsigned int __pyx_v_n) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("int_to_rgb", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_convert__to_py_struct__rgb(__pyx_f_6shader_int_to_rgb(__pyx_v_n, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6388, __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("shader.int_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
6389: """
6390: CONVERT A PYTHON INTEGER INTO A RGB COLOUR MODEL (UNSIGNED CHAR VALUES [0..255]).
6391: EQUIVALENT TO PYGAME UNMAP_RGB()
6392:
6393: Cython cpdef function, this function can be called directly and do not require a
6394: hook function.
6395:
6396: :param n : positive integer value to convert
6397: :return : return a C structure rgb containing RGB values
6398: """
6399: cdef:
6400: rgb rgb_
6401:
+6402: rgb_.r = <float>((n >> 16) & 255)
__pyx_v_rgb_.r = ((float)((__pyx_v_n >> 16) & 0xFF));
+6403: rgb_.g = <float>((n >> 8) & 255)
__pyx_v_rgb_.g = ((float)((__pyx_v_n >> 8) & 0xFF));
+6404: rgb_.b = <float>(n & 255)
__pyx_v_rgb_.b = ((float)(__pyx_v_n & 0xFF));
+6405: return rgb_
__pyx_r = __pyx_v_rgb_; goto __pyx_L0;
6406:
6407:
6408: @cython.boundscheck(False)
6409: @cython.wraparound(False)
6410: @cython.nonecheck(False)
6411: @cython.cdivision(True)
+6412: cdef inline make_palette_c(int width, float fh, float fs, float fl):
static CYTHON_INLINE PyObject *__pyx_f_6shader_make_palette_c(int __pyx_v_width, float __pyx_v_fh, float __pyx_v_fs, float __pyx_v_fl) { __Pyx_memviewslice __pyx_v_palette = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; float __pyx_v_h; float __pyx_v_s; float __pyx_v_l; struct rgb __pyx_v_rgb_; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_palette_c", 0); /* … */ /* 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_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_AddTraceback("shader.make_palette_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_palette, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
6413: """
6414: CREATE A PALETTE (ARRAY) FROM HSL VALUES (HUE, SATURATION, LIGHTNESS)
6415:
6416: e.g:
6417: # below: palette of 256 colors & surface (width=256, height=50).
6418: # hue * 6, saturation = 255.0, lightness * 2.0
6419: palette, surf = make_palette(256, 50, 6, 255, 2)
6420: palette, surf = make_palette(256, 50, 4, 255, 2)
6421:
6422: :param width : integer, Palette width
6423: :param fh : float, hue factor
6424: :param fs : float, saturation factor
6425: :param fl : float, lightness factor
6426: :return : Return a tuple ndarray type uint32 and pygame.Surface (width, height)
6427: """
+6428: assert width > 0, "Argument width should be > 0, got %s " % width
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_width > 0) != 0))) { __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Argument_width_should_be_0_got_s, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(1, 6428, __pyx_L1_error) } } #endif
6429:
6430: cdef:
+6431: unsigned int [::1] palette = numpy.empty(width, uint32)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_numpy); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_t_4}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_t_4}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_4); __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_int(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 6431, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_palette = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
6432: int x, y
6433: float h, s, l
6434: rgb rgb_
6435:
+6436: 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:; } }
+6437: for x in prange(width, schedule='static', num_threads=THREADS):
__pyx_t_6 = __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_10 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_h) lastprivate(__pyx_v_l) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) /* … */ __pyx_t_6 = __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_10 = (__pyx_t_6 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_h) lastprivate(__pyx_v_l) lastprivate(__pyx_v_rgb_) lastprivate(__pyx_v_s) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_9); /* Initialize private variables to invalid values */ __pyx_v_h = ((float)__PYX_NAN()); __pyx_v_l = ((float)__PYX_NAN()); __pyx_v_s = ((float)__PYX_NAN());
+6438: h, s, l = <float>x * fh, min(fs, <float>255.0), min(<float>x * fl, <float>255.0)
__pyx_t_11 = (((float)__pyx_v_x) * __pyx_v_fh); __pyx_t_12 = ((float)255.0); __pyx_t_13 = __pyx_v_fs; if (((__pyx_t_12 < __pyx_t_13) != 0)) { __pyx_t_14 = __pyx_t_12; } else { __pyx_t_14 = __pyx_t_13; } __pyx_t_12 = __pyx_t_14; __pyx_t_14 = ((float)255.0); __pyx_t_13 = (((float)__pyx_v_x) * __pyx_v_fl); if (((__pyx_t_14 < __pyx_t_13) != 0)) { __pyx_t_15 = __pyx_t_14; } else { __pyx_t_15 = __pyx_t_13; } __pyx_t_14 = __pyx_t_15; __pyx_v_h = __pyx_t_11; __pyx_v_s = __pyx_t_12; __pyx_v_l = __pyx_t_14;
+6439: rgb_ = struct_hsl_to_rgb(h * <float>ONE_360, s * <float>ONE_255, l * <float>ONE_255)
__pyx_v_rgb_ = struct_hsl_to_rgb((__pyx_v_h * ((float)0.002777777777777778)), (__pyx_v_s * ((float)0.00392156862745098)), (__pyx_v_l * ((float)0.00392156862745098)));
6440: # build the palette (1d buffer int values)
+6441: palette[x] = rgb_to_int(<int>(rgb_.r * <float>255.0),
__pyx_t_16 = __pyx_v_x; *((unsigned int *) ( /* dim=0 */ ((char *) (((unsigned int *) __pyx_v_palette.data) + __pyx_t_16)) )) = __pyx_f_6shader_rgb_to_int(((int)(__pyx_v_rgb_.r * ((float)255.0))), ((int)(__pyx_v_rgb_.g * ((float)255.0))), ((int)((__pyx_v_rgb_.b * ((float)255.0)) * ((float)0.5))), 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 }
6442: <int>(rgb_.g * <float>255.0),
6443: <int>(rgb_.b * <float>255.0 * <float>0.5))
6444:
+6445: return asarray(palette)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_palette, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 6445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
6446:
6447: @cython.boundscheck(False)
6448: @cython.wraparound(False)
6449: @cython.nonecheck(False)
6450: @cython.cdivision(False)
+6451: cdef fire_surface24_c(
static PyObject *__pyx_f_6shader_fire_surface24_c(int __pyx_v_width, int __pyx_v_height, float __pyx_v_factor, __Pyx_memviewslice __pyx_v_palette, __Pyx_memviewslice __pyx_v_fire, struct __pyx_opt_args_6shader_fire_surface24_c *__pyx_optional_args) { int __pyx_v_intensity = ((int)0); int __pyx_v_low = ((int)0); int __pyx_v_high = ((int)0); __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; float __pyx_v_d; unsigned int __pyx_v_ii; unsigned int __pyx_v_c1; unsigned int __pyx_v_c2; CYTHON_UNUSED int __pyx_v_min_; CYTHON_UNUSED int __pyx_v_max_; int __pyx_v_middle; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_surface24_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_intensity = __pyx_optional_args->intensity; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_low = __pyx_optional_args->low; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_high = __pyx_optional_args->high; } } } } /* … */ /* 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_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_AddTraceback("shader.fire_surface24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+6452: int width,
struct __pyx_opt_args_6shader_fire_surface24_c { int __pyx_n; int intensity; int low; int high; };
6453: int height,
6454: float factor,
6455: unsigned int [::1] palette,
6456: float [:, ::1] fire,
6457: int intensity = 0,
6458: int low = 0,
6459: int high = 0,
6460: ):
6461: """
6462:
6463: CREATE A FIRE EFFECT
6464:
6465: * Do not call this function directly
6466:
6467: :param width : integer; max width of the effect
6468: :param height : integer; max height of the effect
6469: :param factor : float; factor to reduce the flame effect
6470: :param palette : ndarray; Color palette 1d numpy array (colors buffer unsigned int values)
6471: :param fire : ndarray; 2d array (x, y) (contiguous) containing float values
6472: :param intensity: integer; Control the flame intensity default 0 (low intensity), range [0...32]
6473: :param low : integer; The x lowest position of the effect, x must be >=0 and < high
6474: :param high : integer; The x highest position of the effect, x must be > low and <= high
6475: :return : Return a numpy array containing the fire effect array shape
6476: (w, h, 3) of RGB pixels
6477: """
6478:
6479: cdef:
6480: # flame opacity palette
+6481: unsigned char [:, :, ::1] out = zeros((width, height, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6481, __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(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_4, 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(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 6481, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_out = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+6482: int x = 0, y = 0
__pyx_v_x = 0; __pyx_v_y = 0;
6483: float d
+6484: unsigned int ii=0
__pyx_v_ii = 0;
+6485: unsigned c1 = 0, c2 = 0
__pyx_v_c1 = 0; __pyx_v_c2 = 0;
6486:
6487: cdef int min_, max_, middle
6488:
6489:
+6490: if low != 0 or high != 0:
__pyx_t_7 = ((__pyx_v_low != 0) != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = ((__pyx_v_high != 0) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; if (__pyx_t_6) { /* … */ goto __pyx_L3; }
+6491: assert 0 <= low < high, "Argument low_ must be < high_"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = (0 <= __pyx_v_low); if (__pyx_t_6) { __pyx_t_6 = (__pyx_v_low < __pyx_v_high); } if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_low__must_be_high); __PYX_ERR(1, 6491, __pyx_L1_error) } } #endif
+6492: assert high <= width, "Argument high must be <= width"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_high <= __pyx_v_width) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_high_must_be_width); __PYX_ERR(1, 6492, __pyx_L1_error) } } #endif
6493:
+6494: middle = low + ((high - low) >> 1)
__pyx_v_middle = (__pyx_v_low + ((__pyx_v_high - __pyx_v_low) >> 1));
+6495: min_ = randRange(low, middle)
__pyx_v_min_ = randRange(__pyx_v_low, __pyx_v_middle);
+6496: max_ = randRange(middle + 1, high)
__pyx_v_max_ = randRange((__pyx_v_middle + 1), __pyx_v_high);
6497: else:
+6498: middle = width >> 1
/*else*/ { __pyx_v_middle = (__pyx_v_width >> 1);
+6499: min_ = randRange(0, middle)
__pyx_v_min_ = randRange(0, __pyx_v_middle);
+6500: max_ = randRange(middle +1, width)
__pyx_v_max_ = randRange((__pyx_v_middle + 1), __pyx_v_width); } __pyx_L3:;
6501:
6502:
+6503: 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_L8; } __pyx_L7_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L8:; } }
6504: # POPULATE TO THE BASE OF THE FIRE (THIS WILL CONFIGURE THE FLAME ASPECT)
+6505: for x in prange(min_, max_, schedule='static', num_threads=THREADS):
__pyx_t_8 = __pyx_v_min_; __pyx_t_9 = __pyx_v_max_; 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_11 = (__pyx_t_9 - __pyx_t_8 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) __pyx_t_9 = __pyx_v_max_; 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_11 = (__pyx_t_9 - __pyx_t_8 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ { __pyx_v_x = (int)(__pyx_t_8 + 1 * __pyx_t_10);
+6506: fire[height-1, x] = randRange(intensity, 260)
__pyx_t_12 = (__pyx_v_height - 1); __pyx_t_13 = __pyx_v_x; *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_12 * __pyx_v_fire.strides[0]) )) + __pyx_t_13)) )) = randRange(__pyx_v_intensity, 0x104); } } } } } #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
6507:
6508:
6509: # DILUTE THE FLAME EFFECT (DECREASE THE MAXIMUM INT VALUE) WHEN THE FLAME TRAVEL UPWARD
+6510: for y in prange(1, height-1, schedule='static', num_threads=THREADS):
__pyx_t_14 = (__pyx_v_height - 1); 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_16 = (__pyx_t_14 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_16 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_d) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_14 = (__pyx_v_height - 1); 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_16 = (__pyx_t_14 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_16 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_d) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_16; __pyx_t_15++){ { __pyx_v_y = (int)(1 + 1 * __pyx_t_15); /* Initialize private variables to invalid values */ __pyx_v_c1 = ((unsigned int)0xbad0bad0); __pyx_v_c2 = ((unsigned int)0xbad0bad0); __pyx_v_d = ((float)__PYX_NAN()); __pyx_v_ii = ((unsigned int)0xbad0bad0); __pyx_v_x = ((int)0xbad0bad0);
6511:
+6512: for x in range(0, width):
__pyx_t_11 = __pyx_v_width; __pyx_t_10 = __pyx_t_11; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
6513:
+6514: c1 = (y + 1) % height
__pyx_t_17 = (__pyx_v_y + 1); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6514, __pyx_L17_error) } __pyx_v_c1 = __Pyx_mod_long(__pyx_t_17, __pyx_v_height);
+6515: c2 = x % width
if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6515, __pyx_L17_error) } __pyx_v_c2 = __Pyx_mod_int(__pyx_v_x, __pyx_v_width);
+6516: d = (fire[c1, (x - 1 + width) % width]
__pyx_t_17 = ((__pyx_v_x - 1) + __pyx_v_width); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6516, __pyx_L17_error) } __pyx_t_18 = __pyx_v_c1; __pyx_t_13 = __Pyx_mod_long(__pyx_t_17, __pyx_v_width);
+6517: + fire[c1, c2]
__pyx_t_19 = __pyx_v_c1; __pyx_t_20 = __pyx_v_c2;
+6518: + fire[c1, (x + 1) % width]
__pyx_t_21 = (__pyx_v_x + 1); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6518, __pyx_L17_error) } __pyx_t_22 = __pyx_v_c1; __pyx_t_12 = __Pyx_mod_long(__pyx_t_21, __pyx_v_width);
+6519: + fire[(y + 2) % height, c2]) * factor
__pyx_t_23 = (__pyx_v_y + 2); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6519, __pyx_L17_error) } __pyx_t_24 = __Pyx_mod_long(__pyx_t_23, __pyx_v_height); __pyx_t_25 = __pyx_v_c2; __pyx_v_d = (((((*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_18 * __pyx_v_fire.strides[0]) )) + __pyx_t_13)) ))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_19 * __pyx_v_fire.strides[0]) )) + __pyx_t_20)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_22 * __pyx_v_fire.strides[0]) )) + __pyx_t_12)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_24 * __pyx_v_fire.strides[0]) )) + __pyx_t_25)) )))) * __pyx_v_factor);
6520:
+6521: d = d - <float>(rand() * 0.0001)
__pyx_v_d = (__pyx_v_d - ((float)(rand() * 0.0001)));
6522:
6523: # Cap the values
+6524: if d <0:
__pyx_t_6 = ((__pyx_v_d < 0.0) != 0); if (__pyx_t_6) { /* … */ }
+6525: d = 0.0
__pyx_v_d = 0.0;
6526:
6527: # CAP THE VALUE TO 255
+6528: if d>255.0:
__pyx_t_6 = ((__pyx_v_d > 255.0) != 0); if (__pyx_t_6) { /* … */ }
+6529: d = <float>255.0
__pyx_v_d = ((float)255.0);
+6530: fire[y, x] = d
__pyx_t_24 = __pyx_v_y; __pyx_t_12 = __pyx_v_x; *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_24 * __pyx_v_fire.strides[0]) )) + __pyx_t_12)) )) = __pyx_v_d;
6531:
+6532: ii = palette[<unsigned int>d % width]
if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6532, __pyx_L17_error) } __pyx_t_25 = (((unsigned int)__pyx_v_d) % __pyx_v_width); __pyx_v_ii = (*((unsigned int *) ( /* dim=0 */ ((char *) (((unsigned int *) __pyx_v_palette.data) + __pyx_t_25)) )));
6533:
+6534: out[x, y, 0] = (ii >> 16) & 255
__pyx_t_12 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_12 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_13)) )) = ((__pyx_v_ii >> 16) & 0xFF);
+6535: out[x, y, 1] = (ii >> 8) & 255
__pyx_t_13 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_12 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_13 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_12)) )) = ((__pyx_v_ii >> 8) & 0xFF);
+6536: out[x, y, 2] = ii & 255
__pyx_t_12 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_13 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_12 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_13)) )) = (__pyx_v_ii & 0xFF); } goto __pyx_L24; __pyx_L17_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L23; __pyx_L23:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates8) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_c1; __pyx_parallel_temp1 = __pyx_v_c2; __pyx_parallel_temp2 = __pyx_v_d; __pyx_parallel_temp3 = __pyx_v_ii; __pyx_parallel_temp4 = __pyx_v_x; __pyx_parallel_temp5 = __pyx_v_y; } __pyx_L24:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_c1 = __pyx_parallel_temp0; __pyx_v_c2 = __pyx_parallel_temp1; __pyx_v_d = __pyx_parallel_temp2; __pyx_v_ii = __pyx_parallel_temp3; __pyx_v_x = __pyx_parallel_temp4; __pyx_v_y = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L7_error; } } } #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 }
6537:
+6538: return asarray(out)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_out, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
6539:
6540:
6541:
6542: @cython.boundscheck(False)
6543: @cython.wraparound(False)
6544: @cython.nonecheck(False)
6545: @cython.cdivision(False)
+6546: cdef fire_surface24_c_border(
static PyObject *__pyx_f_6shader_fire_surface24_c_border(int __pyx_v_width, int __pyx_v_height, float __pyx_v_factor, __Pyx_memviewslice __pyx_v_palette, __Pyx_memviewslice __pyx_v_fire, struct __pyx_opt_args_6shader_fire_surface24_c_border *__pyx_optional_args) { int __pyx_v_intensity = ((int)0); int __pyx_v_low = ((int)0); int __pyx_v_high = ((int)0); __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; float __pyx_v_d; unsigned int __pyx_v_ii; unsigned int __pyx_v_c1; unsigned int __pyx_v_c2; CYTHON_UNUSED int __pyx_v_min_; CYTHON_UNUSED int __pyx_v_max_; int __pyx_v_middle; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fire_surface24_c_border", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_intensity = __pyx_optional_args->intensity; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_low = __pyx_optional_args->low; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_high = __pyx_optional_args->high; } } } } /* … */ /* 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_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_AddTraceback("shader.fire_surface24_c_border", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+6547: int width,
struct __pyx_opt_args_6shader_fire_surface24_c_border { int __pyx_n; int intensity; int low; int high; };
6548: int height,
6549:
6550: float factor,
6551: unsigned int [::1] palette,
6552: float [:, ::1] fire,
6553: int intensity = 0,
6554: int low = 0,
6555: int high = 0,
6556: ):
6557: """
6558:
6559: CREATE A FIRE EFFECT (BORDER EFFECT)
6560:
6561: * Do not call this function directly
6562:
6563: :param width : integer; max width of the effect
6564: :param height : integer; max height of the effect
6565: :param factor : float; factor to reduce the flame effect
6566: :param palette : ndarray; Color palette 1d numpy array (colors buffer unsigned int values)
6567: :param fire : ndarray; 2d array (x, y) (contiguous) containing float values
6568: :param intensity: integer; Control the flame intensity default 0 (low intensity), range [0...32]
6569: :param low : integer; The x lowest position of the effect, x must be >=0 and < high
6570: :param high : integer; The x highest position of the effect, x must be > low and <= high
6571: :return : Return a numpy array containing the fire effect array
6572: shape (w, h, 3) of RGB pixels
6573: """
6574:
6575: cdef:
6576: # flame opacity palette
+6577: unsigned char [:, :, ::1] out = zeros((width, height, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6577, __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(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_4, 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(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 6577, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_out = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+6578: int x = 0, y = 0
__pyx_v_x = 0; __pyx_v_y = 0;
6579: float d
+6580: unsigned int ii=0
__pyx_v_ii = 0;
+6581: unsigned c1 = 0, c2 = 0
__pyx_v_c1 = 0; __pyx_v_c2 = 0;
6582:
6583: cdef int min_, max_, middle
6584:
6585:
+6586: if low != 0 or high != 0:
__pyx_t_7 = ((__pyx_v_low != 0) != 0); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = ((__pyx_v_high != 0) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; if (__pyx_t_6) { /* … */ goto __pyx_L3; }
+6587: assert 0 <= low < high, "Argument low_ must be < high_"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_6 = (0 <= __pyx_v_low); if (__pyx_t_6) { __pyx_t_6 = (__pyx_v_low < __pyx_v_high); } if (unlikely(!(__pyx_t_6 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_low__must_be_high); __PYX_ERR(1, 6587, __pyx_L1_error) } } #endif
+6588: assert high <= width, "Argument high must be <= width"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_high <= __pyx_v_width) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_high_must_be_width); __PYX_ERR(1, 6588, __pyx_L1_error) } } #endif
6589:
+6590: middle = low + ((high - low) >> 1)
__pyx_v_middle = (__pyx_v_low + ((__pyx_v_high - __pyx_v_low) >> 1));
+6591: min_ = randRange(low, middle)
__pyx_v_min_ = randRange(__pyx_v_low, __pyx_v_middle);
+6592: max_ = randRange(middle + 1, high)
__pyx_v_max_ = randRange((__pyx_v_middle + 1), __pyx_v_high);
6593: else:
+6594: middle = width >> 1
/*else*/ { __pyx_v_middle = (__pyx_v_width >> 1);
+6595: min_ = randRange(0, middle)
__pyx_v_min_ = randRange(0, __pyx_v_middle);
+6596: max_ = randRange(middle +1, width)
__pyx_v_max_ = randRange((__pyx_v_middle + 1), __pyx_v_width); } __pyx_L3:;
6597:
6598:
+6599: 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_L8; } __pyx_L7_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L8:; } }
6600: # POPULATE TO THE BASE OF THE FIRE (THIS WILL CONFIGURE THE FLAME ASPECT)
6601: # for x in prange(min_, max_, schedule='static', num_threads=THREADS
6602: # fire[height - 1, x] = randRange(intensity, 260)
6603:
6604: # FIRE ARRAY IS [HEIGHT, WIDTH]
+6605: for x in prange(min_, max_, schedule='static', num_threads=THREADS):
__pyx_t_8 = __pyx_v_min_; __pyx_t_9 = __pyx_v_max_; 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_11 = (__pyx_t_9 - __pyx_t_8 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) __pyx_t_9 = __pyx_v_max_; 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_11 = (__pyx_t_9 - __pyx_t_8 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ { __pyx_v_x = (int)(__pyx_t_8 + 1 * __pyx_t_10);
+6606: fire[x % height, (height - 1) % width] = randRange(intensity, 260)
if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6606, __pyx_L11_error) } __pyx_t_12 = (__pyx_v_height - 1); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6606, __pyx_L11_error) } __pyx_t_13 = __Pyx_mod_int(__pyx_v_x, __pyx_v_height); __pyx_t_14 = __Pyx_mod_long(__pyx_t_12, __pyx_v_width); *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_13 * __pyx_v_fire.strides[0]) )) + __pyx_t_14)) )) = randRange(__pyx_v_intensity, 0x104); goto __pyx_L14; __pyx_L11_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L13; __pyx_L13:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates9) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_x; } __pyx_L14:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_x = __pyx_parallel_temp0; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L7_error; } } } #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
6607:
6608:
6609: # DILUTE THE FLAME EFFECT (DECREASE THE MAXIMUM INT VALUE) WHEN THE FLAME TRAVEL UPWARD
+6610: for y in prange(1, height - 1, schedule='static', num_threads=THREADS):
__pyx_t_12 = (__pyx_v_height - 1); 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_16 = (__pyx_t_12 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_16 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_d) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_12 = (__pyx_v_height - 1); 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_16 = (__pyx_t_12 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_16 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_d) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_16; __pyx_t_15++){ { __pyx_v_y = (int)(1 + 1 * __pyx_t_15); /* Initialize private variables to invalid values */ __pyx_v_c1 = ((unsigned int)0xbad0bad0); __pyx_v_c2 = ((unsigned int)0xbad0bad0); __pyx_v_d = ((float)__PYX_NAN()); __pyx_v_ii = ((unsigned int)0xbad0bad0); __pyx_v_x = ((int)0xbad0bad0);
6611:
+6612: for x in range(0, width):
__pyx_t_11 = __pyx_v_width; __pyx_t_10 = __pyx_t_11; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
6613:
+6614: c1 = (y + 1) % height
__pyx_t_17 = (__pyx_v_y + 1); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6614, __pyx_L17_error) } __pyx_v_c1 = __Pyx_mod_long(__pyx_t_17, __pyx_v_height);
+6615: c2 = x % width
if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6615, __pyx_L17_error) } __pyx_v_c2 = __Pyx_mod_int(__pyx_v_x, __pyx_v_width);
+6616: d = (fire[c1, (x - 1 + width) % width]
__pyx_t_17 = ((__pyx_v_x - 1) + __pyx_v_width); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6616, __pyx_L17_error) } __pyx_t_18 = __pyx_v_c1; __pyx_t_14 = __Pyx_mod_long(__pyx_t_17, __pyx_v_width);
+6617: + fire[c1, c2]
__pyx_t_19 = __pyx_v_c1; __pyx_t_20 = __pyx_v_c2;
+6618: + fire[c1, (x + 1) % width]
__pyx_t_21 = (__pyx_v_x + 1); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6618, __pyx_L17_error) } __pyx_t_22 = __pyx_v_c1; __pyx_t_13 = __Pyx_mod_long(__pyx_t_21, __pyx_v_width);
+6619: + fire[(y + 2) % height, c2]) * factor
__pyx_t_23 = (__pyx_v_y + 2); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6619, __pyx_L17_error) } __pyx_t_24 = __Pyx_mod_long(__pyx_t_23, __pyx_v_height); __pyx_t_25 = __pyx_v_c2; __pyx_v_d = (((((*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_18 * __pyx_v_fire.strides[0]) )) + __pyx_t_14)) ))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_19 * __pyx_v_fire.strides[0]) )) + __pyx_t_20)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_22 * __pyx_v_fire.strides[0]) )) + __pyx_t_13)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_24 * __pyx_v_fire.strides[0]) )) + __pyx_t_25)) )))) * __pyx_v_factor);
6620:
+6621: d = d - <float>(rand() * 0.0001)
__pyx_v_d = (__pyx_v_d - ((float)(rand() * 0.0001)));
6622:
6623: # Cap the values
+6624: if d <0:
__pyx_t_6 = ((__pyx_v_d < 0.0) != 0); if (__pyx_t_6) { /* … */ }
+6625: d = 0.0
__pyx_v_d = 0.0;
6626:
+6627: if d>255.0:
__pyx_t_6 = ((__pyx_v_d > 255.0) != 0); if (__pyx_t_6) { /* … */ }
+6628: d = <float>255.0
__pyx_v_d = ((float)255.0);
6629:
+6630: fire[x % height , y % width] = d
if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6630, __pyx_L17_error) } if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6630, __pyx_L17_error) } __pyx_t_24 = __Pyx_mod_int(__pyx_v_x, __pyx_v_height); __pyx_t_13 = __Pyx_mod_int(__pyx_v_y, __pyx_v_width); *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_fire.data + __pyx_t_24 * __pyx_v_fire.strides[0]) )) + __pyx_t_13)) )) = __pyx_v_d;
6631:
+6632: ii = palette[<unsigned int>d % width]
if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 6632, __pyx_L17_error) } __pyx_t_25 = (((unsigned int)__pyx_v_d) % __pyx_v_width); __pyx_v_ii = (*((unsigned int *) ( /* dim=0 */ ((char *) (((unsigned int *) __pyx_v_palette.data) + __pyx_t_25)) )));
6633:
+6634: out[x, y, 0] = (ii >> 16) & 255
__pyx_t_13 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_14 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_13 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_14)) )) = ((__pyx_v_ii >> 16) & 0xFF);
+6635: out[x, y, 1] = (ii >> 8) & 255
__pyx_t_14 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_13 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_14 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_13)) )) = ((__pyx_v_ii >> 8) & 0xFF);
+6636: out[x, y, 2] = ii & 255
__pyx_t_13 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_14 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_13 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_14)) )) = (__pyx_v_ii & 0xFF); } goto __pyx_L24; __pyx_L17_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L23; __pyx_L23:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates10) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_c1; __pyx_parallel_temp1 = __pyx_v_c2; __pyx_parallel_temp2 = __pyx_v_d; __pyx_parallel_temp3 = __pyx_v_ii; __pyx_parallel_temp4 = __pyx_v_x; __pyx_parallel_temp5 = __pyx_v_y; } __pyx_L24:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_c1 = __pyx_parallel_temp0; __pyx_v_c2 = __pyx_parallel_temp1; __pyx_v_d = __pyx_parallel_temp2; __pyx_v_ii = __pyx_parallel_temp3; __pyx_v_x = __pyx_parallel_temp4; __pyx_v_y = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L7_error; } } } #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 }
6637:
+6638: return asarray(out)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_out, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
6639:
6640:
6641: # CUSTOM FIRE PALETTE
6642: # arr = numpy.array([0, 1, # violet
6643: # 0, 1, # blue
6644: # 0, 1, # green
6645: # 2, 619, # yellow
6646: # 620, 650, # orange
6647: # 651, 660], # red
6648: # numpy.int)
6649: #
6650: # HEATMAP = [custom_map(i - 20, arr, 1.0) for i in range(380, 800)]
6651: # heatmap_array = numpy.zeros((800 - 380, 3), uint8)
6652: # heatmap_rescale = numpy.zeros(255, numpy.uint)
6653: # i = 0
6654: # for t in HEATMAP:
6655: # heatmap_array[i, 0] = t[0]
6656: # heatmap_array[i, 1] = t[1]
6657: # heatmap_array[i, 2] = t[2]
6658: # i += 1
6659: # for r in range(0, 255):
6660: # s = int(r * (800.0-380.0)/255)
6661: # heatmap_rescale[r] = rgb_to_int(heatmap_array[s][0], heatmap_array[s][1], heatmap_array[s][2])
6662: # heatmap_rescale = numpy.ascontiguousarray(heatmap_rescale[::-1])
6663: # -------- main loop ----
6664: # if frame % 2 == 0:
6665: # surface_ = fire_effect(
6666: # width, height, 3.95 + random.uniform(0.002, 0.008),
6667: # heatmap_rescale,
6668: # FIRE_ARRAY,
6669: # reduce_factor_=3, fire_intensity_=8,
6670: # smooth_=True, bloom_=True, fast_bloom_=True,
6671: # bpf_threshold_=70, low_=0, high_=800, brightness_=True, brightness_intensity_=0.1,
6672: # adjust_palette_=False, hsv_=(10, 80, 1.8), transpose_=False, border_=False, surface_=None)
6673:
6674: @cython.boundscheck(False)
6675: @cython.wraparound(False)
6676: @cython.nonecheck(False)
6677: @cython.cdivision(True)
+6678: cdef inline shader_fire_effect_c(
static CYTHON_INLINE PyObject *__pyx_f_6shader_shader_fire_effect_c(int __pyx_v_width_, int __pyx_v_height_, float __pyx_v_factor_, __Pyx_memviewslice __pyx_v_palette_, __Pyx_memviewslice __pyx_v_fire_, struct __pyx_opt_args_6shader_shader_fire_effect_c *__pyx_optional_args) { unsigned short __pyx_v_reduce_factor_ = ((unsigned short)3); unsigned short __pyx_v_fire_intensity_ = ((unsigned short)32); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1); __Pyx_AddTraceback("shader.shader_fire_effect_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_fire_surface_smallest); __Pyx_XDECREF(__pyx_v_rgb_array_); __Pyx_XDECREF(__pyx_v_fire_effect); __PYX_XDEC_MEMVIEW(&__pyx_v_palette_, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+6679: int width_,
struct __pyx_opt_args_6shader_shader_fire_effect_c { int __pyx_n; unsigned short reduce_factor_; unsigned short fire_intensity_; int smooth_; int bloom_; int fast_bloom_; unsigned char bpf_threshold_; unsigned int low_; unsigned int high_; int brightness_; float brightness_intensity_; PyObject *surface_; int adjust_palette_; PyObject *hsl_; int transpose_; int border_; int blur_; };
6680: int height_,
6681: float factor_,
6682: unsigned int [::1] palette_,
6683: float [:, ::1] fire_,
6684: unsigned short int reduce_factor_ = 3,
6685: unsigned short int fire_intensity_= 32,
+6686: bint smooth_ = True,
int __pyx_v_smooth_ = ((int)1);
+6687: bint bloom_ = True,
int __pyx_v_bloom_ = ((int)1);
+6688: bint fast_bloom_ = True,
int __pyx_v_fast_bloom_ = ((int)1); unsigned char __pyx_v_bpf_threshold_ = ((unsigned char)0); unsigned int __pyx_v_low_ = ((unsigned int)0); unsigned int __pyx_v_high_ = ((unsigned int)0x258);
6689: unsigned char bpf_threshold_ = 0,
6690: unsigned int low_ = 0,
6691: unsigned int high_ = 600,
+6692: bint brightness_ = True,
int __pyx_v_brightness_ = ((int)1); float __pyx_v_brightness_intensity_ = ((float)0.15);
6693: float brightness_intensity_ = 0.15,
+6694: object surface_ = None,
PyObject *__pyx_v_surface_ = ((PyObject *)Py_None);
+6695: bint adjust_palette_ = False,
int __pyx_v_adjust_palette_ = ((int)0);
+6696: tuple hsl_ = (10, 80, 1.8),
PyObject *__pyx_v_hsl_ = ((PyObject*)__pyx_tuple__23); /* … */ __pyx_tuple__23 = PyTuple_Pack(3, __pyx_int_10, __pyx_int_80, __pyx_float_1_8); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 6696, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23);
+6697: bint transpose_ = False,
int __pyx_v_transpose_ = ((int)0);
+6698: bint border_ = False,
int __pyx_v_border_ = ((int)0);
+6699: bint blur_ = True
int __pyx_v_blur_ = ((int)1); int __pyx_v_w4; int __pyx_v_h4; int __pyx_v_f_height; int __pyx_v_f_width; PyObject *__pyx_v_fire_surface_smallest = NULL; PyObject *__pyx_v_rgb_array_ = NULL; PyObject *__pyx_v_fire_effect = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_fire_effect_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_reduce_factor_ = __pyx_optional_args->reduce_factor_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_fire_intensity_ = __pyx_optional_args->fire_intensity_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_smooth_ = __pyx_optional_args->smooth_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_bloom_ = __pyx_optional_args->bloom_; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_fast_bloom_ = __pyx_optional_args->fast_bloom_; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_bpf_threshold_ = __pyx_optional_args->bpf_threshold_; if (__pyx_optional_args->__pyx_n > 6) { __pyx_v_low_ = __pyx_optional_args->low_; if (__pyx_optional_args->__pyx_n > 7) { __pyx_v_high_ = __pyx_optional_args->high_; if (__pyx_optional_args->__pyx_n > 8) { __pyx_v_brightness_ = __pyx_optional_args->brightness_; if (__pyx_optional_args->__pyx_n > 9) { __pyx_v_brightness_intensity_ = __pyx_optional_args->brightness_intensity_; if (__pyx_optional_args->__pyx_n > 10) { __pyx_v_surface_ = __pyx_optional_args->surface_; if (__pyx_optional_args->__pyx_n > 11) { __pyx_v_adjust_palette_ = __pyx_optional_args->adjust_palette_; if (__pyx_optional_args->__pyx_n > 12) { __pyx_v_hsl_ = __pyx_optional_args->hsl_; if (__pyx_optional_args->__pyx_n > 13) { __pyx_v_transpose_ = __pyx_optional_args->transpose_; if (__pyx_optional_args->__pyx_n > 14) { __pyx_v_border_ = __pyx_optional_args->border_; if (__pyx_optional_args->__pyx_n > 15) { __pyx_v_blur_ = __pyx_optional_args->blur_; } } } } } } } } } } } } } } } } } __PYX_INC_MEMVIEW(&__pyx_v_palette_, 1);
6700: ):
6701: """
6702:
6703: FIRE SHADER EFFECT
6704:
6705: * FIRE TEXTURE SIZES
6706:
6707: input width_ : integer,
6708: input height_ : integer
6709:
6710: width_ and height_ values define the size of the texture e.g Surface(width x height)
6711:
6712: * FIRE ASPECT (CONTROL OVER THE WIDTH):
6713:
6714: inputs low_ : integer
6715: input high_ : integer
6716:
6717: Optional arguments low_ & high_ (integer values) define the width 's limits of the fire effect.
6718: low_ for the starting point and high_ for the ending of the effect.
6719: e.g low_ = 10 and high_ = 200. The fire effect will be contain within width = 10 and 200
6720: low_ & high_ values must be in range [0 ... width_]
6721:
6722: * FIRE HEIGHT:
6723:
6724: input factor_ : float
6725:
6726: The fire maximum height can be adjust with the variable factor_ (float value)
6727: value > 3.95 will contain the effect within the display
6728: value < 3.95 will enlarge the effect over the display height
6729: Recommended value is 3.95 with reduce_factor_ = 3 otherwise adjust the value manually
6730: to contain the fire effect within the display
6731:
6732: * SPEED CONSIDERATION
6733:
6734: input reduce_factor_ : integer
6735:
6736: The argument reduce_factor_ control the size of the texture to be processed
6737: e.g : a value of 2, divide by 4 the pygame surface define by the values (width_ & height_)
6738: Smaller texture improve the overall performances but will slightly degrade the fire aspect,
6739: especially if the blur and smooth option are not enabled.
6740: Recommended value for reduce_factor_ is 3 (fast process)
6741: reduce_factor_ values must be an integer in range [ 0 ... 4]
6742: The reduce_factor_ value will have a significant impact on the fire effect maximum height,
6743: adjust the argument factor_ accordingly
6744:
6745: * FIRE INTENSITY AT THE SOURCE
6746:
6747: input fire_intensity_: integer
6748:
6749: Set the fire intensity with the variable fire_intensity_, 0 low flame,
6750: 32 maximum flame effect
6751: Values must be an int in range [0 ... 32]
6752:
6753: * SMOOTHING THE EFFECT
6754:
6755: input smooth_: True | False
6756:
6757: When smooth_ is True the algorithm will use the pygame function smoothscale (bi-linear
6758: filtering) or False the final texture will be adjust with the scale function.
6759: Set this variable to False if you need the best performance for the effect or if you require
6760: a pixelated fire effect. Otherwise set the variable to True for a more realistic effect.
6761:
6762:
6763: * BLOOM EFFECT
6764:
6765: input bloom_ : True | False
6766: input fast_bloom_ : True | False
6767: input bpf_threshold_ : integer
6768:
6769: Fire effect produce a bright and smooth light effect to the background texture where the fire
6770: intensity is at its maximum.
6771: Use the flag fast_bloom_ for a compromise between a realistic effect and the best performances
6772: The flag fast_bloom_ define a very fast bloom algo using only the smallest texture
6773: to create a bloom effect (all the intermediate textures will be bypassed). See the bloom effect
6774: project for more details.
6775: When fast_bloom is False, all the sub-surfaces will be blit to the final effect and will
6776: produce a more realistic fire effect (this will slightly degrade the overall performances).
6777: If the fire effect is too bright, you can always adjust the bright pass filter value
6778: bpf_threshold_(this will adjust the bloom intensity)
6779: bpf_threshold_ value must be in range [ 0 ... 255]
6780: Below 128 the bloom effect will be more noticeable and above 128 only the brightest
6781: area will be enhanced.
6782:
6783: * LIGHT EFFECT INTENSITY
6784:
6785: input brightness_ : True | False
6786: input brightness_intensity_ : float
6787:
6788: When the flag is set to True, the algorithm will use an external function,
6789: <shader_brightness24_exclude_inplace_c> to increase the brightness of the effect / texture
6790: A custom color can be passed to the function defining the pixels to be ignored during the
6791: process (default is black color).
6792: the value must be in range [-1.0 ... 1.0]. Values below zero will decrease the brightness
6793: of the flame effect and positive values will increase the brightness of the effect (causing
6794: bright white patches on the fire texture).
6795: Values below -0.4 will cause the fire effect to be translucent and this effect can also be
6796: used for simulating ascending heat convection effects on a background texture.
6797:
6798:
6799: * OPTIONAL SURFACE
6800:
6801: input surface_ : pygame.Surface
6802:
6803: This is an optional surface that can be passed to the shader to improve the performances
6804: and to avoid a new surface to be generated every iterations. The surface size must match
6805: exactly the reduce texture dimensions otherwise an exception will be raise.
6806: see reduce_factor_ option to determine the fire texture size that will be processed.
6807:
6808: * COLOR PALETTE ADJUSTMENT
6809:
6810: input adjust_palette_ : True | False
6811: input hsl_ : (10, 80, 1.8)
6812:
6813: Set this flag to True to modify the color palette of the fire texture.
6814: This allow the HSL color model to be apply to the palette values
6815: You can redefine the palette when the flag is True and by customizing a tuple of 3 float
6816: values, default is (10, 80, 1.8).
6817: The first value control the palette hue value, the second is for the saturation and last,
6818: the palette color lightness.
6819: With the variable hsl_ you can rotate the palette colors and define a new flame
6820: aspect/color/intensity
6821:
6822: * FLAME ORIENTATION / DIRECTION & BORDER FLAME EFFECT
6823:
6824: input transpose_ = True | False,
6825: input border_ = True | False,
6826:
6827: transpose_ = True, this will transpose the final array
6828: for e.g :
6829: If the final fire texture is (w, h) after setting the transpose flag, the final
6830: fire texture will become (h, w). As a result the fire effect will be transversal (starting
6831: from the right of the display to the left side).
6832: You can always transpose / flip the texture to get the right flame orientation
6833: BORDER FLAME EFFECT
6834: border_ = True to create a flame effect burning the edge of the display
6835:
6836: * FINAL TOUCH
6837:
6838: input blur_ : True | False
6839:
6840: This will will blur the fire effect for a more realistic appearance, remove all the jagged
6841: edge when and pixelated effect
6842:
6843:
6844: :param width_ : integer; Size (width) of the surface or display in pixels
6845: :param height_ : integer; size (height) of the surface or display in pixels
6846: :param factor_ : float; Value controlling the fire height value
6847: must be in range [3.95 ... 4.2].
6848: The value 3.95 gives the highest flame effect
6849: :param palette_ : numpy.ndarray, buffer containing mapped RGB colors (uint values)
6850: :param fire_ : numpy.ndarray shape (w, h) containing float values (fire intensity).
6851: For better performance it is advised to set the array to the size
6852: of the texture after applying the reduction_factor_.
6853: For example if the reduction_factor_ is 2, the texture would have
6854: width >> 1 and height >> 1 and the fire_array should be set to
6855: numpy.empty((height >> 1, width >> 1), float32)
6856: :param reduce_factor_ : unsigned short int ; Can be either 0, 1, 2, 3, 4.
6857: 2 and 3 provide the best performance and the best looking effect.
6858: :param fire_intensity_ : Integer; Control the original amount of energy at the
6859: bottom of the fire, must be in range of [0 ... 32].
6860: 32 being the maximum value and the maximum fire intensity
6861: :param smooth_ : boolean; True smoothscale (bi-linear filtering) or
6862: scale algorithm jagged edges (mush faster)
6863: :param bloom_ : boolean; True or False, True apply a bloom effect to the fire effect
6864: :param fast_bloom_ : boolean; Fastest bloom. This reduce the amount of calculation
6865: :param bpf_threshold_ : integer; control the bright pass filter threshold
6866: value, must be in range [0 ... 255].
6867: Maximum brightness amplification with threshold = 0,
6868: when bpf_threshold_ = 255, no change.
6869: :param low_ : integer; Starting position x for the fire effect
6870: :param high_ : integer; Ending position x for the fire effect
6871: :param brightness_ : boolean; True apply a bright filter shader to the array.
6872: Increase overall brightness of the effect
6873: :param brightness_intensity_: float; must be in range [-1.0 ... 1.0] control
6874: the brightness intensity
6875: of the effect
6876: :param surface_ : pygame.Surface. Pass a surface to the shader for
6877: better performance, otherwise algo is creating a new surface each
6878: calls.
6879: :param adjust_palette_ : boolean; True adjust the palette setting HSL
6880: (hue, saturation, luminescence).
6881: Be aware that if adjust_palette is True, the optional palette
6882: passed to the Shader will be disregarded
6883: :param hsl_ : tuple; float values of hue, saturation and luminescence.
6884: Hue in range [0.0 ... 100], saturation [0...100],
6885: luminescence [0.0 ... 2.0]
6886: :param transpose_ : boolean; Transpose the array (w, h) become (h, w).
6887: The fire effect will start from the left and move to the right
6888: :param border_ : boolean; Flame effect affect the border of the texture
6889: :param blur_ : boolean; Blur the fire effect
6890: :return : Return a pygame surface that can be blit directly to the game display
6891:
6892: """
6893:
6894:
6895: cdef int w4, h4
6896:
6897: # TEXTURE DIVIDE BY POWER OF 2
+6898: if reduce_factor_ in (0, 1, 2):
switch (__pyx_v_reduce_factor_) { case 0: case 1: case 2: /* … */ break; case 3:
+6899: w4, h4 = width_ >> reduce_factor_, height_ >> reduce_factor_
__pyx_t_1 = (__pyx_v_width_ >> __pyx_v_reduce_factor_); __pyx_t_2 = (__pyx_v_height_ >> __pyx_v_reduce_factor_); __pyx_v_w4 = __pyx_t_1; __pyx_v_h4 = __pyx_t_2;
6900:
6901: # TEXTURE 150 x 150 * ratio
+6902: elif reduce_factor_ == 3:
break; case 4:
6903: # CUSTOM SIZE WIDTH 150 AND RATIO * HIGH
+6904: w4 = 150
__pyx_v_w4 = 0x96;
+6905: h4 = <int>(150 * height_/width_)
__pyx_v_h4 = ((int)((0x96 * __pyx_v_height_) / __pyx_v_width_));
+6906: low_ = <int>(low_ * low_/width_)
__pyx_v_low_ = ((int)((__pyx_v_low_ * __pyx_v_low_) / __pyx_v_width_));
+6907: high_ = <int>(high_ * 150/width_)
__pyx_v_high_ = ((int)((__pyx_v_high_ * 0x96) / __pyx_v_width_));
+6908: reduce_factor_ = 0
__pyx_v_reduce_factor_ = 0;
6909:
6910: # TEXTURE 100 x 100 * ratio
+6911: elif reduce_factor_ == 4:
break; default: break; }
+6912: w4 = 100
__pyx_v_w4 = 0x64;
+6913: h4 = <int> (100 * height_ / width_)
__pyx_v_h4 = ((int)((0x64 * __pyx_v_height_) / __pyx_v_width_));
+6914: low_ = <int> (low_ * low_ / width_)
__pyx_v_low_ = ((int)((__pyx_v_low_ * __pyx_v_low_) / __pyx_v_width_));
+6915: high_ = <int> (high_ * 100 / width_)
__pyx_v_high_ = ((int)((__pyx_v_high_ * 0x64) / __pyx_v_width_));
+6916: reduce_factor_ = 0
__pyx_v_reduce_factor_ = 0;
6917:
6918: cdef int f_height, f_width
+6919: f_height, f_width = (<object>fire_).shape[:2]
__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_fire_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_4, 0, 2, NULL, NULL, &__pyx_slice__24, 0, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; 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(1, 6919, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(1, 6919, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 6919, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_f_height = __pyx_t_2; __pyx_v_f_width = __pyx_t_1; /* … */ __pyx_slice__24 = PySlice_New(Py_None, __pyx_int_2, Py_None); if (unlikely(!__pyx_slice__24)) __PYX_ERR(1, 6919, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__24); __Pyx_GIVEREF(__pyx_slice__24);
6920:
+6921: assert f_width >= w4 or f_height >= h4,\
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_9 = ((__pyx_v_f_width >= __pyx_v_w4) != 0); if (!__pyx_t_9) { } else { __pyx_t_8 = __pyx_t_9; goto __pyx_L5_bool_binop_done; } __pyx_t_9 = ((__pyx_v_f_height >= __pyx_v_h4) != 0); __pyx_t_8 = __pyx_t_9; __pyx_L5_bool_binop_done:; if (unlikely(!__pyx_t_8)) {
6922: "Fire array size mismatch the texture size.\n" \
+6923: "Set fire_ array to numpy.empty((%s, %s), dtype=numpy.float32)" % (h4, w4)
__pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Fire_array_size_mismatch_the_tex, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(1, 6921, __pyx_L1_error) } } #endif
6924:
+6925: if surface_ is None:
__pyx_t_8 = (__pyx_v_surface_ == Py_None); __pyx_t_9 = (__pyx_t_8 != 0); if (__pyx_t_9) { /* … */ goto __pyx_L7; }
+6926: fire_surface_smallest = pygame.Surface((w4, h4)).convert()
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pygame); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Surface); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); __pyx_t_3 = 0; __pyx_t_10 = 0; __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_10, __pyx_t_11) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_convert); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_5 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6926, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_fire_surface_smallest = __pyx_t_5; __pyx_t_5 = 0;
6927:
6928: else:
+6929: if PyObject_IsInstance(surface_, pygame.Surface):
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pygame); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6929, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Surface); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6929, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_6); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 6929, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = (__pyx_t_9 != 0); if (likely(__pyx_t_8)) { /* … */ goto __pyx_L8; }
+6930: assert surface_.get_width() == w4 and surface_.get_height() == h4, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_width); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_9) { } else { __pyx_t_8 = __pyx_t_9; goto __pyx_L9_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_height); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(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_4 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(1, 6930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = __pyx_t_9; __pyx_L9_bool_binop_done:; if (unlikely(!__pyx_t_8)) {
6931: "Surface argument has incorrect dimension surface must be (w:%s, h:%s) got (%s, %s)\n" \
6932: "Set argument surface_ to None to avoid this error message"\
+6933: % (w4, h4, surface_.get_width(), surface_.get_height())
__pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_width); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); } } __pyx_t_4 = (__pyx_t_10) ? __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10) : __Pyx_PyObject_CallNoArg(__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_height); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } __pyx_t_11 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_10); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_11); __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_4 = 0; __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyString_Format(__pyx_kp_s_Surface_argument_has_incorrect_d, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_11); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(1, 6930, __pyx_L1_error) } } #endif
+6934: fire_surface_smallest = surface_
__Pyx_INCREF(__pyx_v_surface_);
__pyx_v_fire_surface_smallest = __pyx_v_surface_;
6935: else:
+6936: raise ValueError("Argument surface_ must be a Surface type got %s " % type(surface_))
/*else*/ { __pyx_t_11 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_Surf, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6936, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6936, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(1, 6936, __pyx_L1_error) } __pyx_L8:; } __pyx_L7:;
6937:
+6938: if adjust_palette_:
__pyx_t_8 = (__pyx_v_adjust_palette_ != 0); if (__pyx_t_8) { /* … */ }
+6939: palette_= make_palette_c(w4, hsl_[0], hsl_[1], hsl_[2])
if (unlikely(__pyx_v_hsl_ == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6939, __pyx_L1_error) } __pyx_t_12 = __pyx_PyFloat_AsFloat(PyTuple_GET_ITEM(__pyx_v_hsl_, 0)); if (unlikely((__pyx_t_12 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 6939, __pyx_L1_error) if (unlikely(__pyx_v_hsl_ == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6939, __pyx_L1_error) } __pyx_t_13 = __pyx_PyFloat_AsFloat(PyTuple_GET_ITEM(__pyx_v_hsl_, 1)); if (unlikely((__pyx_t_13 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 6939, __pyx_L1_error) if (unlikely(__pyx_v_hsl_ == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(1, 6939, __pyx_L1_error) } __pyx_t_14 = __pyx_PyFloat_AsFloat(PyTuple_GET_ITEM(__pyx_v_hsl_, 2)); if (unlikely((__pyx_t_14 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 6939, __pyx_L1_error) __pyx_t_10 = __pyx_f_6shader_make_palette_c(__pyx_v_w4, __pyx_t_12, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_dc_unsigned_int(__pyx_t_10, PyBUF_WRITABLE); if (unlikely(!__pyx_t_15.memview)) __PYX_ERR(1, 6939, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_palette_, 1); __pyx_v_palette_ = __pyx_t_15; __pyx_t_15.memview = NULL; __pyx_t_15.data = NULL;
6940:
+6941: if border_:
__pyx_t_8 = (__pyx_v_border_ != 0); if (__pyx_t_8) { /* … */ goto __pyx_L12; }
6942: # CREATE THE FIRE EFFECT ONTO A PYGAME SURFACE
+6943: rgb_array_ = fire_surface24_c_border(
__pyx_t_16.__pyx_n = 3; __pyx_t_16.intensity = __pyx_v_fire_intensity_; __pyx_t_16.low = (__pyx_v_low_ >> __pyx_v_reduce_factor_); __pyx_t_16.high = (__pyx_v_high_ >> __pyx_v_reduce_factor_); __pyx_t_10 = __pyx_f_6shader_fire_surface24_c_border(__pyx_v_w4, __pyx_v_h4, (((float)1.0) / __pyx_v_factor_), __pyx_v_palette_, __pyx_v_fire_, &__pyx_t_16); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_rgb_array_ = __pyx_t_10; __pyx_t_10 = 0;
6944: w4, h4, <float>1.0 / factor_, palette_, fire_, fire_intensity_,
6945: low_ >> reduce_factor_, high_ >> reduce_factor_)
6946: else:
+6947: rgb_array_ = fire_surface24_c(
/*else*/ { /* … */ __pyx_t_17.__pyx_n = 3; __pyx_t_17.intensity = __pyx_v_fire_intensity_; __pyx_t_17.low = (__pyx_v_low_ >> __pyx_v_reduce_factor_); __pyx_t_17.high = (__pyx_v_high_ >> __pyx_v_reduce_factor_); __pyx_t_10 = __pyx_f_6shader_fire_surface24_c(__pyx_v_w4, __pyx_v_h4, (((float)1.0) / __pyx_v_factor_), __pyx_v_palette_, __pyx_v_fire_, &__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6947, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_rgb_array_ = __pyx_t_10; __pyx_t_10 = 0; } __pyx_L12:;
6948: w4, h4, <float>1.0 / factor_, palette_, fire_, fire_intensity_,
6949: low_ >> reduce_factor_, high_ >> reduce_factor_)
6950:
6951: # BRIGHTNESS SHADER
+6952: if brightness_:
__pyx_t_8 = (__pyx_v_brightness_ != 0); if (__pyx_t_8) { /* … */ }
6953: # EXCLUDE BLACK COLORS (DEFAULT)
+6954: assert -1.0 <= brightness_intensity_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_8 = (-1.0 <= __pyx_v_brightness_intensity_); if (__pyx_t_8) { __pyx_t_8 = (__pyx_v_brightness_intensity_ <= 1.0); } if (unlikely(!(__pyx_t_8 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_brightness_intensity_mu); __PYX_ERR(1, 6954, __pyx_L1_error) } } #endif
6955: "Argument brightness intensity must be in range [-1.0 ... 1.0]"
+6956: shader_brightness24_exclude_inplace_c(rgb_array_=rgb_array_,
__pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(1, 6956, __pyx_L1_error) /* … */ __pyx_t_19.__pyx_n = 2; __pyx_t_19.shift_ = __pyx_v_brightness_intensity_; __pyx_t_19.color_ = __pyx_tuple__9; __pyx_f_6shader_shader_brightness24_exclude_inplace_c(__pyx_t_18, &__pyx_t_19); __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1); __pyx_t_18.memview = NULL; __pyx_t_18.data = NULL;
6957: shift_=brightness_intensity_, color_=(0, 0, 0))
6958:
+6959: if blur_:
__pyx_t_8 = (__pyx_v_blur_ != 0); if (__pyx_t_8) { /* … */ }
+6960: shader_blur5x5_array24_inplace_c(rgb_array_)
__pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(1, 6960, __pyx_L1_error) __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_18, NULL); __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1); __pyx_t_18.memview = NULL; __pyx_t_18.data = NULL;
6961:
+6962: if transpose_:
__pyx_t_8 = (__pyx_v_transpose_ != 0); if (__pyx_t_8) { /* … */ }
+6963: rgb_array_ = rgb_array_.transpose(1, 0, 2)
__pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_rgb_array_, __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6963, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6963, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_rgb_array_, __pyx_t_11); __pyx_t_11 = 0; /* … */ __pyx_tuple__25 = PyTuple_Pack(3, __pyx_int_1, __pyx_int_0, __pyx_int_2); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 6963, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25);
+6964: fire_surface_smallest = rotate(fire_surface_smallest, 90)
__Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_rotate); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_fire_surface_smallest, __pyx_int_90}; __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6964, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_fire_surface_smallest, __pyx_int_90}; __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6964, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_fire_surface_smallest); __Pyx_GIVEREF(__pyx_v_fire_surface_smallest); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_1, __pyx_v_fire_surface_smallest); __Pyx_INCREF(__pyx_int_90); __Pyx_GIVEREF(__pyx_int_90); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_1, __pyx_int_90); __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_fire_surface_smallest, __pyx_t_11); __pyx_t_11 = 0;
6965:
6966:
6967: # CONVERT THE ARRAY INTO A PYGAME SURFACE
+6968: array_to_surface(fire_surface_smallest, rgb_array_)
__Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_array_to_surface); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_fire_surface_smallest, __pyx_v_rgb_array_}; __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6968, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_fire_surface_smallest, __pyx_v_rgb_array_}; __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6968, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_11); } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_fire_surface_smallest); __Pyx_GIVEREF(__pyx_v_fire_surface_smallest); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_1, __pyx_v_fire_surface_smallest); __Pyx_INCREF(__pyx_v_rgb_array_); __Pyx_GIVEREF(__pyx_v_rgb_array_); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_1, __pyx_v_rgb_array_); __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
6969:
6970:
6971: # BLOOM SHADER EFFECT
+6972: if bloom_:
__pyx_t_8 = (__pyx_v_bloom_ != 0); if (__pyx_t_8) { /* … */ }
+6973: assert 0 <= bpf_threshold_ < 256, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_8 = (0 <= __pyx_v_bpf_threshold_); if (__pyx_t_8) { __pyx_t_8 = (__pyx_v_bpf_threshold_ < 0x100); } if (unlikely(!(__pyx_t_8 != 0))) {
+6974: "Argument bpf_threshold_ must be in range [0 ... 256] got %s " % bpf_threshold_
__pyx_t_11 = __Pyx_PyInt_From_unsigned_char(__pyx_v_bpf_threshold_); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_Argument_bpf_threshold__must_be, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(1, 6973, __pyx_L1_error) } } #endif
+6975: shader_bloom_effect_array24_c(fire_surface_smallest, bpf_threshold_, fast_=fast_bloom_)
__pyx_t_20.__pyx_n = 1; __pyx_t_20.fast_ = __pyx_v_fast_bloom_; __pyx_f_6shader_shader_bloom_effect_array24_c(__pyx_v_fire_surface_smallest, __pyx_v_bpf_threshold_, &__pyx_t_20);
6976:
6977: # RESCALE THE SURFACE TO THE FULL SIZE
+6978: if smooth_:
__pyx_t_8 = (__pyx_v_smooth_ != 0); if (__pyx_t_8) { /* … */ goto __pyx_L17; }
+6979: fire_effect = smoothscale(fire_surface_smallest, (width_, height_))
__Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_width_); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_height_); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_fire_surface_smallest, __pyx_t_6}; __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_fire_surface_smallest, __pyx_t_6}; __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_v_fire_surface_smallest); __Pyx_GIVEREF(__pyx_v_fire_surface_smallest); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_1, __pyx_v_fire_surface_smallest); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_fire_effect = __pyx_t_10; __pyx_t_10 = 0;
6980: else:
+6981: fire_effect = scale(fire_surface_smallest, (width_, height_))
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_scale); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_width_); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_height_); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); __pyx_t_4 = 0; __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_fire_surface_smallest, __pyx_t_5}; __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_fire_surface_smallest, __pyx_t_5}; __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_fire_surface_smallest); __Pyx_GIVEREF(__pyx_v_fire_surface_smallest); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_1, __pyx_v_fire_surface_smallest); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_1, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 6981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_fire_effect = __pyx_t_10; __pyx_t_10 = 0; } __pyx_L17:;
6982:
+6983: return fire_effect
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_fire_effect); __pyx_r = __pyx_v_fire_effect; goto __pyx_L0;
6984:
6985:
6986:
6987: @cython.boundscheck(False)
6988: @cython.wraparound(False)
6989: @cython.nonecheck(False)
6990: @cython.cdivision(False)
+6991: cdef cloud_surface24_c(
static PyObject *__pyx_f_6shader_cloud_surface24_c(int __pyx_v_width, int __pyx_v_height, float __pyx_v_factor, __Pyx_memviewslice __pyx_v_palette, __Pyx_memviewslice __pyx_v_cloud_, struct __pyx_opt_args_6shader_cloud_surface24_c *__pyx_optional_args) { int __pyx_v_intensity = ((int)0); int __pyx_v_low = ((int)0); int __pyx_v_high = ((int)0); int __pyx_v_new_height; __Pyx_memviewslice __pyx_v_out = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; float __pyx_v_d; unsigned int __pyx_v_ii; unsigned int __pyx_v_c1; unsigned int __pyx_v_c2; int __pyx_v_p_length; CYTHON_UNUSED int __pyx_v_min_; CYTHON_UNUSED int __pyx_v_max_; int __pyx_v_middle; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cloud_surface24_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_intensity = __pyx_optional_args->intensity; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_low = __pyx_optional_args->low; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_high = __pyx_optional_args->high; } } } } /* … */ /* 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_XDEC_MEMVIEW(&__pyx_t_5, 1); __Pyx_AddTraceback("shader.cloud_surface24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_out, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+6992: int width,
struct __pyx_opt_args_6shader_cloud_surface24_c { int __pyx_n; int intensity; int low; int high; };
6993: int height,
6994: float factor,
6995: unsigned int [::1] palette,
6996: float [:, ::1] cloud_,
6997: int intensity = 0,
6998: int low = 0,
6999: int high = 0,
7000: ):
7001:
7002: """
7003: CLOUD PROCESSING FUNCTION
7004:
7005: * Do not call that function directly, this function is a sub function of cloud_effect
7006:
7007: :param width : integer; Size (width) of the surface or display in pixels
7008: :param height : integer; size (height) of the surface or display in pixels
7009: :param factor : float; Value controlling the cloud size value must
7010: be in range [3.95 ... 4.2].
7011: value 3.95 will fill entirely the display with the cloud while value
7012: above 3.95 will shrink the cloud effect
7013: :param palette : numpy.ndarray, buffer containing mapped RGB colors (uint values)
7014: :param cloud_ : numpy.ndarray shape (w, h) containing float values (cloud intensity).
7015: :param intensity: integer; Determine the guaranteed amount of smoke the cloud
7016: effect will generate at the base
7017: of the effect (value must be in range [0 .. 260]). If you provide zero a
7018: random value between 0 ... 260 will be
7019: assigned. If you provide 250, a random value between 250 and 260 will be set.
7020: :param low : integer; low determine the X starting position on the display,
7021: if you provide a value of
7022: 100 pixels, the effect will start at the position 100 from the display
7023: (first 100 pixels will bot be affected by the cloud/smoke effect)
7024: :param high : integer; high determine the X ending position on the display,
7025: if you provide a value of 800 pixels, the effect will end at the
7026: position 800 from the display (last remaining pixels will not be affected
7027: by the cloud/smoke effect)
7028: :return : Return a numpy array shape (w, h, 3) containing the RGB pixels (smoke effect)
7029: """
7030:
7031: cdef:
+7032: int new_height = height
__pyx_v_new_height = __pyx_v_height;
+7033: unsigned char [:, :, ::1] out = empty((width, new_height, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_new_height); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_4, 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(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(1, 7033, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_out = __pyx_t_5; __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL;
+7034: int x = 0, y = 0
__pyx_v_x = 0; __pyx_v_y = 0;
7035: float d
+7036: unsigned int ii=0
__pyx_v_ii = 0;
+7037: unsigned c1 = 0, c2 = 0
__pyx_v_c1 = 0; __pyx_v_c2 = 0;
+7038: int p_length = (<object>palette).size
__pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_palette, 1, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_int, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_int, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7038, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_p_length = __pyx_t_6;
7039:
7040: cdef int min_, max_, middle
7041:
+7042: if low != 0 or high != 0:
__pyx_t_8 = ((__pyx_v_low != 0) != 0); if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L4_bool_binop_done; } __pyx_t_8 = ((__pyx_v_high != 0) != 0); __pyx_t_7 = __pyx_t_8; __pyx_L4_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L3; }
+7043: assert 0 <= low < high, "Argument low_ must be < high_"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = (0 <= __pyx_v_low); if (__pyx_t_7) { __pyx_t_7 = (__pyx_v_low < __pyx_v_high); } if (unlikely(!(__pyx_t_7 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_low__must_be_high); __PYX_ERR(1, 7043, __pyx_L1_error) } } #endif
+7044: assert high <= width, "Argument high must be <= width"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_high <= __pyx_v_width) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_high_must_be_width); __PYX_ERR(1, 7044, __pyx_L1_error) } } #endif
7045:
+7046: middle = low + ((high - low) >> 1)
__pyx_v_middle = (__pyx_v_low + ((__pyx_v_high - __pyx_v_low) >> 1));
+7047: min_ = randRange(low, middle)
__pyx_v_min_ = randRange(__pyx_v_low, __pyx_v_middle);
+7048: max_ = randRange(middle + 1, high)
__pyx_v_max_ = randRange((__pyx_v_middle + 1), __pyx_v_high);
7049: else:
+7050: middle = width >> 1
/*else*/ { __pyx_v_middle = (__pyx_v_width >> 1);
+7051: min_ = randRange(0, middle)
__pyx_v_min_ = randRange(0, __pyx_v_middle);
+7052: max_ = randRange(middle +1, width)
__pyx_v_max_ = randRange((__pyx_v_middle + 1), __pyx_v_width); } __pyx_L3:;
7053:
7054:
+7055: 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_L8; } __pyx_L7_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L8:; } }
7056: # POPULATE TO THE BASE OF THE FIRE (THIS WILL CONFIGURE THE FLAME ASPECT)
+7057: for x in prange(min_, max_, schedule='static', num_threads=THREADS):
__pyx_t_6 = __pyx_v_min_; __pyx_t_9 = __pyx_v_max_; 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_11 = (__pyx_t_9 - __pyx_t_6 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) __pyx_t_9 = __pyx_v_max_; 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_11 = (__pyx_t_9 - __pyx_t_6 + 1 - 1/abs(1)) / 1; if (__pyx_t_11 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ { __pyx_v_x = (int)(__pyx_t_6 + 1 * __pyx_t_10);
+7058: cloud_[(new_height - 1) % height, x % width] = randRange(intensity, 260)
__pyx_t_12 = (__pyx_v_new_height - 1); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7058, __pyx_L11_error) } if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7058, __pyx_L11_error) } __pyx_t_13 = __Pyx_mod_long(__pyx_t_12, __pyx_v_height); __pyx_t_14 = __Pyx_mod_int(__pyx_v_x, __pyx_v_width); *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_cloud_.data + __pyx_t_13 * __pyx_v_cloud_.strides[0]) )) + __pyx_t_14)) )) = randRange(__pyx_v_intensity, 0x104); goto __pyx_L14; __pyx_L11_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L13; __pyx_L13:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates11) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_x; } __pyx_L14:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_x = __pyx_parallel_temp0; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L7_error; } } } #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
7059:
7060:
7061: # DILUTE THE FLAME EFFECT (DECREASE THE MAXIMUM INT VALUE) WHEN THE FLAME TRAVEL UPWARD
+7062: for y in prange(0, new_height - 1, schedule='static', num_threads=THREADS):
__pyx_t_12 = (__pyx_v_new_height - 1); 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_16 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_16 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_d) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_12 = (__pyx_v_new_height - 1); 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_16 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_16 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_d) lastprivate(__pyx_v_ii) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_16; __pyx_t_15++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_15); /* Initialize private variables to invalid values */ __pyx_v_c1 = ((unsigned int)0xbad0bad0); __pyx_v_c2 = ((unsigned int)0xbad0bad0); __pyx_v_d = ((float)__PYX_NAN()); __pyx_v_ii = ((unsigned int)0xbad0bad0); __pyx_v_x = ((int)0xbad0bad0);
7063:
+7064: for x in range(0, width):
__pyx_t_11 = __pyx_v_width; __pyx_t_10 = __pyx_t_11; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
7065:
+7066: c1 = (y + 1) % height
__pyx_t_17 = (__pyx_v_y + 1); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7066, __pyx_L17_error) } __pyx_v_c1 = __Pyx_mod_long(__pyx_t_17, __pyx_v_height);
+7067: c2 = x % width
if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7067, __pyx_L17_error) } __pyx_v_c2 = __Pyx_mod_int(__pyx_v_x, __pyx_v_width);
+7068: d = (cloud_[c1, (x - 1 + width) % width]
__pyx_t_17 = ((__pyx_v_x - 1) + __pyx_v_width); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7068, __pyx_L17_error) } __pyx_t_18 = __pyx_v_c1; __pyx_t_14 = __Pyx_mod_long(__pyx_t_17, __pyx_v_width);
+7069: + cloud_[c1, c2]
__pyx_t_19 = __pyx_v_c1; __pyx_t_20 = __pyx_v_c2;
+7070: + cloud_[c1, (x + 1) % width]
__pyx_t_21 = (__pyx_v_x + 1); if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7070, __pyx_L17_error) } __pyx_t_22 = __pyx_v_c1; __pyx_t_13 = __Pyx_mod_long(__pyx_t_21, __pyx_v_width);
+7071: + cloud_[(y + 2) % height, c2]) * factor
__pyx_t_23 = (__pyx_v_y + 2); if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7071, __pyx_L17_error) } __pyx_t_24 = __Pyx_mod_long(__pyx_t_23, __pyx_v_height); __pyx_t_25 = __pyx_v_c2; __pyx_v_d = (((((*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_cloud_.data + __pyx_t_18 * __pyx_v_cloud_.strides[0]) )) + __pyx_t_14)) ))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_cloud_.data + __pyx_t_19 * __pyx_v_cloud_.strides[0]) )) + __pyx_t_20)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_cloud_.data + __pyx_t_22 * __pyx_v_cloud_.strides[0]) )) + __pyx_t_13)) )))) + (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_cloud_.data + __pyx_t_24 * __pyx_v_cloud_.strides[0]) )) + __pyx_t_25)) )))) * __pyx_v_factor);
7072:
+7073: d = d - <float>(rand() * 0.0001)
__pyx_v_d = (__pyx_v_d - ((float)(rand() * 0.0001)));
7074:
7075: # Cap the values
+7076: if d <0:
__pyx_t_7 = ((__pyx_v_d < 0.0) != 0); if (__pyx_t_7) { /* … */ }
+7077: d = 0.0
__pyx_v_d = 0.0;
7078:
7079: # CAP THE VALUE TO 255
+7080: if d>512.0:
__pyx_t_7 = ((__pyx_v_d > 512.0) != 0); if (__pyx_t_7) { /* … */ }
+7081: d = <float>512.0
__pyx_v_d = ((float)512.0);
+7082: cloud_[y % height, x % width] = d
if (unlikely(__pyx_v_height == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7082, __pyx_L17_error) } if (unlikely(__pyx_v_width == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7082, __pyx_L17_error) } __pyx_t_24 = __Pyx_mod_int(__pyx_v_y, __pyx_v_height); __pyx_t_13 = __Pyx_mod_int(__pyx_v_x, __pyx_v_width); *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_cloud_.data + __pyx_t_24 * __pyx_v_cloud_.strides[0]) )) + __pyx_t_13)) )) = __pyx_v_d;
7083:
+7084: ii = palette[<unsigned int>d % p_length]
if (unlikely(__pyx_v_p_length == 0)) { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif __PYX_ERR(1, 7084, __pyx_L17_error) } __pyx_t_25 = (((unsigned int)__pyx_v_d) % __pyx_v_p_length); __pyx_v_ii = (*((unsigned int *) ( /* dim=0 */ ((char *) (((unsigned int *) __pyx_v_palette.data) + __pyx_t_25)) )));
7085:
+7086: out[x, y, 0] = (ii >> 16) & 255
__pyx_t_13 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_14 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_13 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_14)) )) = ((__pyx_v_ii >> 16) & 0xFF);
+7087: out[x, y, 1] = (ii >> 8) & 255
__pyx_t_14 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_13 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_14 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_13)) )) = ((__pyx_v_ii >> 8) & 0xFF);
+7088: out[x, y, 2] = ii & 255
__pyx_t_13 = __pyx_v_x; __pyx_t_24 = __pyx_v_y; __pyx_t_14 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_out.data + __pyx_t_13 * __pyx_v_out.strides[0]) ) + __pyx_t_24 * __pyx_v_out.strides[1]) )) + __pyx_t_14)) )) = (__pyx_v_ii & 0xFF); } goto __pyx_L24; __pyx_L17_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L23; __pyx_L23:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates12) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_c1; __pyx_parallel_temp1 = __pyx_v_c2; __pyx_parallel_temp2 = __pyx_v_d; __pyx_parallel_temp3 = __pyx_v_ii; __pyx_parallel_temp4 = __pyx_v_x; __pyx_parallel_temp5 = __pyx_v_y; } __pyx_L24:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_c1 = __pyx_parallel_temp0; __pyx_v_c2 = __pyx_parallel_temp1; __pyx_v_d = __pyx_parallel_temp2; __pyx_v_ii = __pyx_parallel_temp3; __pyx_v_x = __pyx_parallel_temp4; __pyx_v_y = __pyx_parallel_temp5; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L7_error; } } } #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 }
7089:
+7090: return asarray(out[:, 0:height, :])
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_asarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5.data = __pyx_v_out.data; __pyx_t_5.memview = __pyx_v_out.memview; __PYX_INC_MEMVIEW(&__pyx_t_5, 0); __pyx_t_5.shape[0] = __pyx_v_out.shape[0]; __pyx_t_5.strides[0] = __pyx_v_out.strides[0]; __pyx_t_5.suboffsets[0] = -1; __pyx_t_11 = -1; if (unlikely(__pyx_memoryview_slice_memviewslice( &__pyx_t_5, __pyx_v_out.shape[1], __pyx_v_out.strides[1], __pyx_v_out.suboffsets[1], 1, 1, &__pyx_t_11, 0, __pyx_v_height, 0, 1, 1, 0, 1) < 0)) { __PYX_ERR(1, 7090, __pyx_L1_error) } __pyx_t_5.shape[2] = __pyx_v_out.shape[2]; __pyx_t_5.strides[2] = __pyx_v_out.strides[2]; __pyx_t_5.suboffsets[2] = -1; __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_5, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1); __pyx_t_5.memview = NULL; __pyx_t_5.data = NULL; __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_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7090, __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;
7091:
7092:
7093: # CLOUD ARRAY PALETTE
7094: # cloud_rescale = numpy.zeros(256 * 2 * 3, numpy.uint)
7095: #
7096: # arr1 = create_horizontal_gradient_1d(255, (0, 0, 0), (255, 255, 255))
7097: # arr2 = create_horizontal_gradient_1d(255, (255, 255, 255), (0, 0, 0))
7098: # arr3 = numpy.concatenate((arr1, arr2), axis=None)
7099: # i = 0
7100: # for r in range(0, 1530, 3):
7101: # cloud_rescale[i] = rgb_to_int(arr3[r], arr3[r+1], arr3[r+2])
7102: # i += 1
7103: # -------- main loop ----------
7104: # surface_ = cloud_effect(
7105: # width, height, 3.956 + random.uniform(0.002, 0.008),
7106: # heatmap_rescale,
7107: # CLOUD_ARRAY,
7108: # reduce_factor_=2, cloud_intensity_=75,
7109: # smooth_=True, bloom_=False, fast_bloom_=True,
7110: # bpf_threshold_=80, low_=0, high_=800, brightness_=False, brightness_intensity_=0.1,
7111: # transpose_=False, surface_=None, blur_=False)
7112:
7113: # TODO MASK ? TO MOVE CLOUD ?
7114:
7115: @cython.boundscheck(False)
7116: @cython.wraparound(False)
7117: @cython.nonecheck(False)
7118: @cython.cdivision(False)
+7119: cdef inline shader_cloud_effect_c(
static CYTHON_INLINE PyObject *__pyx_f_6shader_shader_cloud_effect_c(int __pyx_v_width_, int __pyx_v_height_, float __pyx_v_factor_, __Pyx_memviewslice __pyx_v_palette_, __Pyx_memviewslice __pyx_v_cloud_, struct __pyx_opt_args_6shader_shader_cloud_effect_c *__pyx_optional_args) { unsigned short __pyx_v_reduce_factor_ = ((unsigned short)2); unsigned short __pyx_v_cloud_intensity_ = ((unsigned short)16); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1); __Pyx_AddTraceback("shader.shader_cloud_effect_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cloud_surface_smallest); __Pyx_XDECREF(__pyx_v_rgb_array_); __Pyx_XDECREF(__pyx_v_cloud_effect); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+7120: int width_,
struct __pyx_opt_args_6shader_shader_cloud_effect_c { int __pyx_n; unsigned short reduce_factor_; unsigned short cloud_intensity_; int smooth_; int bloom_; int fast_bloom_; unsigned short bpf_threshold_; unsigned int low_; unsigned int high_; int brightness_; float brightness_intensity_; PyObject *surface_; int transpose_; int blur_; };
7121: int height_,
7122: float factor_,
7123: unsigned int [::1] palette_,
7124: float [:, ::1] cloud_,
7125:
7126: # OPTIONAL
7127: unsigned short int reduce_factor_ = 2,
7128: unsigned short int cloud_intensity_ = 16,
+7129: bint smooth_ = True,
int __pyx_v_smooth_ = ((int)1);
+7130: bint bloom_ = False,
int __pyx_v_bloom_ = ((int)0);
+7131: bint fast_bloom_ = True,
int __pyx_v_fast_bloom_ = ((int)1); unsigned short __pyx_v_bpf_threshold_ = ((unsigned short)0x80); unsigned int __pyx_v_low_ = ((unsigned int)0); unsigned int __pyx_v_high_ = ((unsigned int)0);
7132: unsigned short int bpf_threshold_ = 128,
7133: unsigned int low_ = 0,
7134: unsigned int high_ = 0,
+7135: bint brightness_ = False,
int __pyx_v_brightness_ = ((int)0); float __pyx_v_brightness_intensity_ = ((float)0.0);
7136: float brightness_intensity_ = 0.0,
+7137: object surface_ = None,
PyObject *__pyx_v_surface_ = ((PyObject *)Py_None);
+7138: bint transpose_ = False,
int __pyx_v_transpose_ = ((int)0);
+7139: bint blur_ = True
int __pyx_v_blur_ = ((int)1); int __pyx_v_w4; int __pyx_v_h4; int __pyx_v_f_height; int __pyx_v_f_width; PyObject *__pyx_v_cloud_surface_smallest = NULL; PyObject *__pyx_v_rgb_array_ = NULL; PyObject *__pyx_v_cloud_effect = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_cloud_effect_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_reduce_factor_ = __pyx_optional_args->reduce_factor_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_cloud_intensity_ = __pyx_optional_args->cloud_intensity_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_smooth_ = __pyx_optional_args->smooth_; if (__pyx_optional_args->__pyx_n > 3) { __pyx_v_bloom_ = __pyx_optional_args->bloom_; if (__pyx_optional_args->__pyx_n > 4) { __pyx_v_fast_bloom_ = __pyx_optional_args->fast_bloom_; if (__pyx_optional_args->__pyx_n > 5) { __pyx_v_bpf_threshold_ = __pyx_optional_args->bpf_threshold_; if (__pyx_optional_args->__pyx_n > 6) { __pyx_v_low_ = __pyx_optional_args->low_; if (__pyx_optional_args->__pyx_n > 7) { __pyx_v_high_ = __pyx_optional_args->high_; if (__pyx_optional_args->__pyx_n > 8) { __pyx_v_brightness_ = __pyx_optional_args->brightness_; if (__pyx_optional_args->__pyx_n > 9) { __pyx_v_brightness_intensity_ = __pyx_optional_args->brightness_intensity_; if (__pyx_optional_args->__pyx_n > 10) { __pyx_v_surface_ = __pyx_optional_args->surface_; if (__pyx_optional_args->__pyx_n > 11) { __pyx_v_transpose_ = __pyx_optional_args->transpose_; if (__pyx_optional_args->__pyx_n > 12) { __pyx_v_blur_ = __pyx_optional_args->blur_; } } } } } } } } } } } } } }
7140: ):
7141: """
7142: GENERATE CLOUD /SMOKE ON THE GAME DISPLAY
7143:
7144: * CLOUD TEXTURE SIZES
7145:
7146: input width_ : integer,
7147: input height_ : integer
7148:
7149: width_ and height_ values define the size of the texture e.g Surface(width x height)
7150:
7151: * CLOUD ASPECT (CONTROL OVER THE WIDTH):
7152:
7153: inputs low_ : integer
7154: input high_ : integer
7155:
7156: Optional arguments low_ & high_ (integer values) define the width 's limits of the cloud
7157: effect. low_ for the starting point and high_ for the ending of the effect.
7158: e.g low_ = 10 and high_ = 200. The cloud effect will be contain within width = 10 and 200
7159: low_ & high_ values must be in range [0 ... width_]
7160:
7161: * CLOUD HEIGHT:
7162:
7163: input factor_ : float
7164:
7165: The cloud maximum height can be adjust with the variable factor_ (float value)
7166: value > 3.95 will contain the effect within the display
7167: value < 3.95 will enlarge the effect over the display height
7168: Recommended value is 3.95 with reduce_factor_ = 3 otherwise adjust the value manually
7169: to contain the cloud effect within the display
7170:
7171: * SPEED CONSIDERATION
7172:
7173: input reduce_factor_ : integer
7174:
7175: The argument reduce_factor_ control the size of the texture to be processed
7176: e.g : a value of 2, divide by 4 the pygame surface define by the values (width_ & height_)
7177: Smaller texture improve the overall performances but will slightly degrade the cloud aspect,
7178: especially if the blur and smooth option are not enabled.
7179: Recommended value for reduce_factor_ is 3 (fast process)
7180: reduce_factor_ values must be an integer in range [ 0 ... 4]
7181: The reduce_factor_ value will have a significant impact on the cloud effect maximum height,
7182: adjust the argument factor_ accordingly
7183:
7184: * CLOUD INTENSITY AT THE SOURCE
7185:
7186: input cloud_intensity_: integer
7187:
7188: Set the cloud intensity with the variable cloud_intensity_, 0 low flame,
7189: 32 maximum flame effect
7190: Values must be an int in range [0 ... 32]
7191:
7192: * SMOOTHING THE EFFECT
7193:
7194: input smooth_: True | False
7195:
7196: When smooth_ is True the algorithm will use the pygame function smoothscale (bi-linear
7197: filtering) or False the final texture will be adjust with the scale function.
7198: Set this variable to False if you need the best performance for the effect or if you require
7199: a pixelated cloud effect. Otherwise set the variable to True for a more realistic effect.
7200:
7201: * BLOOM EFFECT
7202:
7203: input bloom_ : True | False
7204: input fast_bloom_ : True | False
7205: input bpf_threshold_ : integer
7206:
7207: Bloom effect produce a bright and smooth light effect to the background texture where the cloud
7208: intensity is at its maximum.
7209: Use the flag fast_bloom_ for a compromise between a realistic effect and the best performances
7210: The flag fast_bloom_ define a very fast bloom algo using only the smallest texture
7211: to create a bloom effect (all the intermediate textures will be bypassed). See the bloom effect
7212: project for more details.
7213: When fast_bloom is False, all the sub-surfaces will be blit to the final effect and will
7214: produce a more realistic cloud effect (this will slightly degrade the overall performances).
7215: If the cloud effect is too bright, you can always adjust the bright pass filter value
7216: bpf_threshold_(this will adjust the bloom intensity)
7217: bpf_threshold_ value must be in range [ 0 ... 255]
7218: Below 128 the bloom effect will be more noticeable and above 128 only the brightest
7219: area will be enhanced.
7220:
7221: * LIGHT EFFECT INTENSITY
7222:
7223: input brightness_ : True | False
7224: input brightness_intensity_ : float
7225:
7226: When the flag is set to True, the algorithm will use an external function,
7227: <shader_brightness24_exclude_inplace_c> to increase the brightness of the effect / texture
7228: A custom color can be passed to the function defining the pixels to be ignored during the
7229: process (default is black color).
7230: the value must be in range [-1.0 ... 1.0]. Values below zero will decrease the brightness
7231: of the cloud effect and positive values will increase the brightness of the effect (causing
7232: bright white patches on the cloud texture).
7233: Values below -0.4 will cause the cloud effect to be translucent
7234:
7235:
7236: * OPTIONAL SURFACE
7237:
7238: input surface_ : pygame.Surface
7239:
7240: This is an optional surface that can be passed to the shader to improve the performances
7241: and to avoid a new surface to be generated every iterations. The surface size must match
7242: exactly the reduce texture dimensions otherwise an exception will be raise.
7243: see reduce_factor_ option to determine the cloud texture size that will be processed.
7244:
7245:
7246: * CLOUD ORIENTATION / DIRECTION
7247:
7248: input transpose_ = True | False,
7249:
7250: transpose_ = True, this will transpose the final array
7251: for e.g :
7252: If the final cloud texture is (w, h) after setting the transpose flag, the final
7253: cloud texture will become (h, w). As a result the cloud effect will be transversal (starting
7254: from the right of the display to the left side).
7255: You can always transpose / flip the texture to get the right cloud orientation
7256:
7257: * FINAL TOUCH
7258:
7259: input blur_ : True | False
7260:
7261: This will will blur the cloud effect for a more realistic appearance, remove all the jagged
7262: edge when and pixelated effect
7263:
7264: :param width_ : integer; Texture size (width)
7265: :param height_ : integer; Texture size (height)
7266: :param factor_ : float; Floating value used to control the size of the cloud
7267: effect. Value must be in range [3.95 ... 4.2]. Value > 3.95
7268: will contain the smoke/ cloud effect within the display.
7269: Values < 3.95 will enlarge the smoke effect.
7270: :param palette_ : numpy.ndarray or cython memoryview containing the color for the
7271: cloud effect (buffer containing mapped RGB colors (uint values))
7272: :param cloud_ : numpy.ndarray shape (w, h) containing float values
7273: (cloud intensity). For better performance it is advised to set the
7274: array to the size of the texture after applying the
7275: reduction_factor_. For example if the reduction_factor_ is 2,
7276: the texture would have to be width >> 1 and height >> 1 and the
7277: cloud_ array should be equivalent to numpy.empty((height >> 1,
7278: width >> 1), float32)
7279: :param reduce_factor_ : integer; unsigned short int ; Can be either 0, 1, 2, 3, 4.
7280: 2 and 3 provide the best performance and the best looking effect.
7281: :param cloud_intensity_ : integer; Determine the amount of smoke the cloud
7282: effect will generate at the base of the effect (value must be in
7283: range [0 .. 260]). If you provide zero a random value between
7284: 0 ... 260 will be assigned. If you provide 250, a random value
7285: between 250 and 260 will be set for the amount of smoke.
7286: The highest the value, the more dense the cloud effect will be
7287: :param smooth_ : boolean; True use a smoothscale (bi-linear filtering) or
7288: False -> scale algorithm jagged edges (mush faster)
7289: :param bloom_ : True | False, Add a bloom effect when the flag is set to True
7290: The bloom effect will smooth the cloud and create a dense smoke
7291: areas where the cloud is the brightest.
7292: :param fast_bloom_ : True | False; This set a fast algorithm for the bloom effect (the
7293: bloom effect will use the smallest texture)
7294: :param bpf_threshold_ : integer; Bright pass filter value must be in range [ 0 ... 255]
7295: 0 produce the maximum bloom effect
7296: :param low_ : integer; must be in range [ 0 ... width_], left position of the
7297: cloud effect
7298: :param high_ : integer; must be in range [ 0 ... height_], right position of the
7299: cloud effect
7300: :param brightness_ : True | False; Increase the brightness of the cloud effect when
7301: True
7302: :param brightness_intensity_: float; Set the brightness intensity of the cloud. The value must
7303: be in range [-1.0 ... +1.0]. Changing the value overtime will
7304: generate a realistic cloud effect. Negative value will generate
7305: translucent patch of smoke on the background image
7306: :param surface_ : Pygame.Surface; Pass a surface to the shader for
7307: better performance, otherwise a new surface will be created each
7308: calls.
7309: :param transpose_ : boolean; Transpose the array (w, h) become (h, w).
7310: The cloud effect will start from the left and move to the right
7311: :param blur_ : boolean; Blur the cloud effect
7312: :return : Return a pygame surface that can be blit directly to the game
7313: display
7314: """
7315:
7316:
7317: cdef int w4, h4
7318:
7319: # TEXTURE DIVIDE BY POWER OF 2
+7320: if reduce_factor_ in (0, 1, 2):
switch (__pyx_v_reduce_factor_) { case 0: case 1: case 2: /* … */ break; case 3:
+7321: w4, h4 = width_ >> reduce_factor_, height_ >> reduce_factor_
__pyx_t_1 = (__pyx_v_width_ >> __pyx_v_reduce_factor_); __pyx_t_2 = (__pyx_v_height_ >> __pyx_v_reduce_factor_); __pyx_v_w4 = __pyx_t_1; __pyx_v_h4 = __pyx_t_2;
7322:
7323: # TEXTURE 150 x 150 * ratio
+7324: elif reduce_factor_ == 3:
break; case 4:
7325: # CUSTOM SIZE WIDTH 150 AND RATIO * HIGH
+7326: w4 = 150
__pyx_v_w4 = 0x96;
+7327: h4 = <int>(150 * height_/width_)
__pyx_t_3 = (0x96 * __pyx_v_height_); if (unlikely(__pyx_v_width_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 7327, __pyx_L1_error) } else if (sizeof(long) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_width_ == (int)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_3))) { PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); __PYX_ERR(1, 7327, __pyx_L1_error) } __pyx_v_h4 = ((int)__Pyx_div_long(__pyx_t_3, __pyx_v_width_));
+7328: low_ = <int>(low_ * low_/width_)
__pyx_t_4 = (__pyx_v_low_ * __pyx_v_low_); if (unlikely(__pyx_v_width_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 7328, __pyx_L1_error) } __pyx_v_low_ = ((int)(__pyx_t_4 / __pyx_v_width_));
+7329: high_ = <int>(high_ * 150/width_)
__pyx_t_3 = (__pyx_v_high_ * 0x96); if (unlikely(__pyx_v_width_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 7329, __pyx_L1_error) } else if (sizeof(long) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_width_ == (int)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_3))) { PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); __PYX_ERR(1, 7329, __pyx_L1_error) } __pyx_v_high_ = ((int)__Pyx_div_long(__pyx_t_3, __pyx_v_width_));
+7330: reduce_factor_ = 0
__pyx_v_reduce_factor_ = 0;
7331:
7332: # TEXTURE 100 x 100 * ratio
+7333: elif reduce_factor_ == 4:
break; default: break; }
+7334: w4 = 100
__pyx_v_w4 = 0x64;
+7335: h4 = <int> (100 * height_ / width_)
__pyx_t_3 = (0x64 * __pyx_v_height_); if (unlikely(__pyx_v_width_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 7335, __pyx_L1_error) } else if (sizeof(long) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_width_ == (int)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_3))) { PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); __PYX_ERR(1, 7335, __pyx_L1_error) } __pyx_v_h4 = ((int)__Pyx_div_long(__pyx_t_3, __pyx_v_width_));
+7336: low_ = <int> (low_ * low_ / width_)
__pyx_t_4 = (__pyx_v_low_ * __pyx_v_low_); if (unlikely(__pyx_v_width_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 7336, __pyx_L1_error) } __pyx_v_low_ = ((int)(__pyx_t_4 / __pyx_v_width_));
+7337: high_ = <int> (high_ * 100 / width_)
__pyx_t_3 = (__pyx_v_high_ * 0x64); if (unlikely(__pyx_v_width_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(1, 7337, __pyx_L1_error) } else if (sizeof(long) == sizeof(long) && (!(((int)-1) > 0)) && unlikely(__pyx_v_width_ == (int)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_3))) { PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); __PYX_ERR(1, 7337, __pyx_L1_error) } __pyx_v_high_ = ((int)__Pyx_div_long(__pyx_t_3, __pyx_v_width_));
+7338: reduce_factor_ = 0
__pyx_v_reduce_factor_ = 0;
7339:
7340: cdef int f_height, f_width
+7341: f_height, f_width = (<object> cloud_).shape[:2]
__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_cloud_, 2, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, 2, NULL, NULL, &__pyx_slice__24, 0, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; 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(1, 7341, __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_7 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_7 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) __PYX_ERR(1, 7341, __pyx_L1_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 7341, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7341, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_f_height = __pyx_t_2; __pyx_v_f_width = __pyx_t_1;
7342:
+7343: assert f_width >= w4 or f_height >= h4, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_11 = ((__pyx_v_f_width >= __pyx_v_w4) != 0); if (!__pyx_t_11) { } else { __pyx_t_10 = __pyx_t_11; goto __pyx_L5_bool_binop_done; } __pyx_t_11 = ((__pyx_v_f_height >= __pyx_v_h4) != 0); __pyx_t_10 = __pyx_t_11; __pyx_L5_bool_binop_done:; if (unlikely(!__pyx_t_10)) {
7344: "Cloud array size mismatch the texture size.\n" \
+7345: "Set cloud array to numpy.empty((%s, %s), dtype=numpy.float32)" % (h4, w4)
__pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); __pyx_t_5 = 0; __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Cloud_array_size_mismatch_the_te, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_7); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(1, 7343, __pyx_L1_error) } } #endif
7346:
+7347: if surface_ is None:
__pyx_t_10 = (__pyx_v_surface_ == Py_None); __pyx_t_11 = (__pyx_t_10 != 0); if (__pyx_t_11) { /* … */ goto __pyx_L7; }
+7348: cloud_surface_smallest = pygame.Surface((w4, h4)).convert()
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pygame); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Surface); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); __pyx_t_5 = 0; __pyx_t_12 = 0; __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_6 = (__pyx_t_12) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_12, __pyx_t_13) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_13); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_convert); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); } } __pyx_t_7 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_8); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_cloud_surface_smallest = __pyx_t_7; __pyx_t_7 = 0;
7349:
7350: else:
+7351: if PyObject_IsInstance(surface_, pygame.Surface):
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pygame); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Surface); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_11 = PyObject_IsInstance(__pyx_v_surface_, __pyx_t_8); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 7351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = (__pyx_t_11 != 0); if (likely(__pyx_t_10)) { /* … */ goto __pyx_L8; }
+7352: assert surface_.get_width() == w4 and surface_.get_height() == h4, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_width); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_8 = (__pyx_t_6) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallNoArg(__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyObject_RichCompare(__pyx_t_8, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_11) { } else { __pyx_t_10 = __pyx_t_11; goto __pyx_L9_bool_binop_done; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_height); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_6 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyObject_RichCompare(__pyx_t_6, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(1, 7352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __pyx_t_11; __pyx_L9_bool_binop_done:; if (unlikely(!__pyx_t_10)) {
7353: "Surface argument has incorrect dimension surface must be (w:%s, h:%s) got (%s, %s)\n" \
7354: "Set argument surface_ to None to avoid this error message"\
+7355: % (w4, h4, surface_.get_width(), surface_.get_height())
__pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_w4); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_h4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_width); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); } } __pyx_t_6 = (__pyx_t_12) ? __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12) : __Pyx_PyObject_CallNoArg(__pyx_t_13); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_height); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } __pyx_t_13 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_12); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyTuple_New(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 3, __pyx_t_13); __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyString_Format(__pyx_kp_s_Surface_argument_has_incorrect_d, __pyx_t_12); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7355, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_13); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __PYX_ERR(1, 7352, __pyx_L1_error) } } #endif
+7356: cloud_surface_smallest = surface_
__Pyx_INCREF(__pyx_v_surface_);
__pyx_v_cloud_surface_smallest = __pyx_v_surface_;
7357: else:
+7358: raise ValueError("Argument surface_ must be a Surface type got %s " % type(surface_))
/*else*/ { __pyx_t_13 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Argument_surface__must_be_a_Surf, ((PyObject *)Py_TYPE(__pyx_v_surface_))); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(1, 7358, __pyx_L1_error) } __pyx_L8:; } __pyx_L7:;
7359:
+7360: rgb_array_ = cloud_surface24_c(
__pyx_t_14.__pyx_n = 3; __pyx_t_14.intensity = __pyx_v_cloud_intensity_; __pyx_t_14.low = (__pyx_v_low_ >> __pyx_v_reduce_factor_); __pyx_t_14.high = (__pyx_v_high_ >> __pyx_v_reduce_factor_); __pyx_t_12 = __pyx_f_6shader_cloud_surface24_c(__pyx_v_w4, __pyx_v_h4, (((float)1.0) / __pyx_v_factor_), __pyx_v_palette_, __pyx_v_cloud_, &__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7360, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_v_rgb_array_ = __pyx_t_12; __pyx_t_12 = 0;
+7361: w4, h4, <float>1.0 / factor_, palette_, cloud_, cloud_intensity_,
if (unlikely(__pyx_v_factor_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 7361, __pyx_L1_error) }
7362: low_ >> reduce_factor_, high_ >> reduce_factor_)
7363:
7364: # BRIGHTNESS SHADER
+7365: if brightness_:
__pyx_t_10 = (__pyx_v_brightness_ != 0); if (__pyx_t_10) { /* … */ }
7366: # EXCLUDE BLACK COLORS (DEFAULT)
+7367: assert -1.0 <= brightness_intensity_ <= 1.0, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_10 = (-1.0 <= __pyx_v_brightness_intensity_); if (__pyx_t_10) { __pyx_t_10 = (__pyx_v_brightness_intensity_ <= 1.0); } if (unlikely(!(__pyx_t_10 != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_brightness_intensity_mu); __PYX_ERR(1, 7367, __pyx_L1_error) } } #endif
7368: "Argument brightness intensity must be in range [-1.0 ... 1.0]"
+7369: shader_brightness24_exclude_inplace_c(rgb_array_=rgb_array_,
__pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_15.memview)) __PYX_ERR(1, 7369, __pyx_L1_error) /* … */ __pyx_t_16.__pyx_n = 2; __pyx_t_16.shift_ = __pyx_v_brightness_intensity_; __pyx_t_16.color_ = __pyx_tuple__9; __pyx_f_6shader_shader_brightness24_exclude_inplace_c(__pyx_t_15, &__pyx_t_16); __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1); __pyx_t_15.memview = NULL; __pyx_t_15.data = NULL;
7370: shift_=brightness_intensity_, color_=(0, 0, 0))
7371:
+7372: if blur_:
__pyx_t_10 = (__pyx_v_blur_ != 0); if (__pyx_t_10) { /* … */ }
+7373: shader_blur5x5_array24_inplace_c(rgb_array_)
__pyx_t_15 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_rgb_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_15.memview)) __PYX_ERR(1, 7373, __pyx_L1_error) __pyx_f_6shader_shader_blur5x5_array24_inplace_c(__pyx_t_15, NULL); __PYX_XDEC_MEMVIEW(&__pyx_t_15, 1); __pyx_t_15.memview = NULL; __pyx_t_15.data = NULL;
7374:
+7375: if transpose_:
__pyx_t_10 = (__pyx_v_transpose_ != 0); if (__pyx_t_10) { /* … */ goto __pyx_L13; }
+7376: rgb_array_ = rgb_array_.transpose(1, 0, 2)
__pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_rgb_array_, __pyx_n_s_transpose_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF_SET(__pyx_v_rgb_array_, __pyx_t_13); __pyx_t_13 = 0;
+7377: cloud_surface_smallest = make_surface(rgb_array_)
__Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); } } __pyx_t_13 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_12, __pyx_t_6, __pyx_v_rgb_array_) : __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_rgb_array_); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF_SET(__pyx_v_cloud_surface_smallest, __pyx_t_13); __pyx_t_13 = 0;
7378: else:
7379: # CONVERT THE ARRAY INTO A PYGAME SURFACE
+7380: array_to_surface(cloud_surface_smallest, rgb_array_)
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_array_to_surface); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7380, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_cloud_surface_smallest, __pyx_v_rgb_array_}; __pyx_t_13 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7380, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_13); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_cloud_surface_smallest, __pyx_v_rgb_array_}; __pyx_t_13 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7380, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_13); } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7380, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_cloud_surface_smallest); __Pyx_GIVEREF(__pyx_v_cloud_surface_smallest); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_1, __pyx_v_cloud_surface_smallest); __Pyx_INCREF(__pyx_v_rgb_array_); __Pyx_GIVEREF(__pyx_v_rgb_array_); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_1, __pyx_v_rgb_array_); __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_7, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7380, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_L13:;
7381:
7382:
7383: # BLOOM SHADER EFFECT
+7384: if bloom_:
__pyx_t_10 = (__pyx_v_bloom_ != 0); if (__pyx_t_10) { /* … */ }
+7385: assert 0 <= bpf_threshold_ < 256, \
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { __pyx_t_10 = (0 <= __pyx_v_bpf_threshold_); if (__pyx_t_10) { __pyx_t_10 = (__pyx_v_bpf_threshold_ < 0x100); } if (unlikely(!(__pyx_t_10 != 0))) {
+7386: "Argument bpf_threshold_ must be in range [0 ... 256] got %s " % bpf_threshold_
__pyx_t_13 = __Pyx_PyInt_From_unsigned_short(__pyx_v_bpf_threshold_); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyString_Format(__pyx_kp_s_Argument_bpf_threshold__must_be, __pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; PyErr_SetObject(PyExc_AssertionError, __pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(1, 7385, __pyx_L1_error) } } #endif
+7387: shader_bloom_effect_array24_c(cloud_surface_smallest, bpf_threshold_, fast_=fast_bloom_)
__pyx_t_17.__pyx_n = 1; __pyx_t_17.fast_ = __pyx_v_fast_bloom_; __pyx_f_6shader_shader_bloom_effect_array24_c(__pyx_v_cloud_surface_smallest, __pyx_v_bpf_threshold_, &__pyx_t_17);
7388:
7389: # RESCALE THE SURFACE TO THE FULL SIZE
+7390: if smooth_:
__pyx_t_10 = (__pyx_v_smooth_ != 0); if (__pyx_t_10) { /* … */ goto __pyx_L15; }
+7391: cloud_effect = smoothscale(cloud_surface_smallest, (width_, height_))
__Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_width_); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_height_); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_cloud_surface_smallest, __pyx_t_8}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_cloud_surface_smallest, __pyx_t_8}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_cloud_surface_smallest); __Pyx_GIVEREF(__pyx_v_cloud_surface_smallest); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_1, __pyx_v_cloud_surface_smallest); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_1, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_7, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_v_cloud_effect = __pyx_t_12; __pyx_t_12 = 0;
7392: else:
+7393: cloud_effect = scale(cloud_surface_smallest, (width_, height_))
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_scale); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_width_); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_height_); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_8); __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_1 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_1 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_cloud_surface_smallest, __pyx_t_6}; __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) { PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_cloud_surface_smallest, __pyx_t_6}; __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-__pyx_t_1, 2+__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_7 = PyTuple_New(2+__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (__pyx_t_8) { __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); __pyx_t_8 = NULL; } __Pyx_INCREF(__pyx_v_cloud_surface_smallest); __Pyx_GIVEREF(__pyx_v_cloud_surface_smallest); PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_1, __pyx_v_cloud_surface_smallest); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_1, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_7, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(1, 7393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_v_cloud_effect = __pyx_t_12; __pyx_t_12 = 0; } __pyx_L15:;
7394:
+7395: return cloud_effect
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_cloud_effect); __pyx_r = __pyx_v_cloud_effect; goto __pyx_L0;
7396:
7397:
7398:
7399: @cython.boundscheck(False)
7400: @cython.wraparound(False)
7401: @cython.nonecheck(False)
7402: @cython.cdivision(True)
+7403: cdef inline mirroring_c(unsigned char[:, :, :] rgb_array_):
static CYTHON_INLINE PyObject *__pyx_f_6shader_mirroring_c(__Pyx_memviewslice __pyx_v_rgb_array_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_x2; int __pyx_v_x3; int __pyx_v_x; int __pyx_v_y; __Pyx_memviewslice __pyx_v_new_array = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_AddTraceback("shader.mirroring_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_new_array, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7404:
7405: """
7406: SHADER MIRRORING
7407:
7408: This method create a mirror image placed to the right side of the
7409: original image referenced by rgb_array_
7410:
7411: The Array (rgb_array) must be a numpy array shape (w, h, 3)
7412: containing RGB pixels, please refer to pygame
7413: function pixels3d or array3d to convert an image into a 3d
7414: array (library surfarray)
7415:
7416: :param rgb_array_: numpy ndarray shape (w, h, 3) containing RGB pixels
7417: :return : returns a numpy ndarray shape (w, h, 3) with transformation
7418: """
7419:
7420: cdef:
7421: Py_ssize_t w, h
7422: int x2, x3
+7423: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
7424:
7425:
7426: cdef:
7427: int x, y
+7428: unsigned char [:, :, :] new_array = empty((w, h, 3), uint8)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_3); __pyx_t_6 = 0; __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_uint8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; __pyx_t_9 = 0; 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_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_8, __pyx_t_7}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_8, __pyx_t_7}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7); __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 7428, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_new_array = __pyx_t_11; __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
7429: unsigned char *r
7430: unsigned char *g
7431: unsigned char *b
7432:
+7433: 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:; } }
+7434: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_12 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_r) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_x3) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_3 = __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_12 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_r) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_x3) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_12; __pyx_t_2++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_r = ((unsigned char *)1); __pyx_v_x2 = ((int)0xbad0bad0); __pyx_v_x3 = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0);
+7435: for y in range(h):
__pyx_t_13 = __pyx_v_h; __pyx_t_14 = __pyx_t_13; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_14; __pyx_t_9+=1) { __pyx_v_y = __pyx_t_9;
7436:
+7437: r = &rgb_array_[x, y, 0]
__pyx_t_15 = __pyx_v_x; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[2]) ))));
+7438: g = &rgb_array_[x, y, 1]
__pyx_t_17 = __pyx_v_x; __pyx_t_16 = __pyx_v_y; __pyx_t_15 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_17 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))));
+7439: b = &rgb_array_[x, y, 2]
__pyx_t_15 = __pyx_v_x; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[2]) ))));
7440:
+7441: x2 = x >> 1
__pyx_v_x2 = (__pyx_v_x >> 1);
+7442: new_array[x2, y, 0] = r[0]
__pyx_t_17 = __pyx_v_x2; __pyx_t_16 = __pyx_v_y; __pyx_t_15 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_17 * __pyx_v_new_array.strides[0]) ) + __pyx_t_16 * __pyx_v_new_array.strides[1]) ) + __pyx_t_15 * __pyx_v_new_array.strides[2]) )) = (__pyx_v_r[0]);
+7443: new_array[x2, y, 1] = g[0]
__pyx_t_15 = __pyx_v_x2; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_15 * __pyx_v_new_array.strides[0]) ) + __pyx_t_16 * __pyx_v_new_array.strides[1]) ) + __pyx_t_17 * __pyx_v_new_array.strides[2]) )) = (__pyx_v_g[0]);
+7444: new_array[x2, y, 2] = b[0]
__pyx_t_17 = __pyx_v_x2; __pyx_t_16 = __pyx_v_y; __pyx_t_15 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_17 * __pyx_v_new_array.strides[0]) ) + __pyx_t_16 * __pyx_v_new_array.strides[1]) ) + __pyx_t_15 * __pyx_v_new_array.strides[2]) )) = (__pyx_v_b[0]);
+7445: x3 = <int>w - x2 -1
__pyx_v_x3 = ((((int)__pyx_v_w) - __pyx_v_x2) - 1);
+7446: new_array[x3, y, 0] = r[0]
__pyx_t_15 = __pyx_v_x3; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_15 * __pyx_v_new_array.strides[0]) ) + __pyx_t_16 * __pyx_v_new_array.strides[1]) ) + __pyx_t_17 * __pyx_v_new_array.strides[2]) )) = (__pyx_v_r[0]);
+7447: new_array[x3, y, 1] = g[0]
__pyx_t_17 = __pyx_v_x3; __pyx_t_16 = __pyx_v_y; __pyx_t_15 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_17 * __pyx_v_new_array.strides[0]) ) + __pyx_t_16 * __pyx_v_new_array.strides[1]) ) + __pyx_t_15 * __pyx_v_new_array.strides[2]) )) = (__pyx_v_g[0]);
+7448: new_array[x3, y, 2] = b[0]
__pyx_t_15 = __pyx_v_x3; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_new_array.data + __pyx_t_15 * __pyx_v_new_array.strides[0]) ) + __pyx_t_16 * __pyx_v_new_array.strides[1]) ) + __pyx_t_17 * __pyx_v_new_array.strides[2]) )) = (__pyx_v_b[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 }
7449:
+7450: return asarray(new_array)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __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_10)) __PYX_ERR(1, 7450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_4 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
7451:
7452:
7453:
7454: @cython.boundscheck(False)
7455: @cython.wraparound(False)
7456: @cython.nonecheck(False)
7457: @cython.cdivision(True)
+7458: cdef inline mirroring_inplace_c(unsigned char[:, :, :] rgb_array_):
static CYTHON_INLINE PyObject *__pyx_f_6shader_mirroring_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; int __pyx_v_x2; int __pyx_v_x3; int __pyx_v_x; int __pyx_v_y; __Pyx_memviewslice __pyx_v_rgb_array_copy = { 0, 0, { 0 }, { 0 }, { 0 } }; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("mirroring_inplace_c", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_AddTraceback("shader.mirroring_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_copy, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7459:
7460: """
7461: SHADER MIRRORING (INPLACE)
7462:
7463: This method create a mirror image placed to the right side of
7464: the original image referenced by rgb_array_
7465:
7466: The Array (rgb_array) must be a numpy array shape (w, h, 3)
7467: containing RGB pixels, please refer to pygame
7468: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
7469:
7470: :param rgb_array_: numpy ndarray shape (w, h, 3) containing RGB pixels
7471: :return : void
7472: """
7473:
7474: cdef:
7475: Py_ssize_t w, h
7476: int x2, x3
+7477: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
7478:
7479: cdef:
7480: int x, y
+7481: unsigned char [:, :, :] rgb_array_copy = numpy.array(rgb_array_, copy=True)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_numpy); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_True) < 0) __PYX_ERR(1, 7481, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_7, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 7481, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_v_rgb_array_copy = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
7482: unsigned char *r
7483: unsigned char *g
7484: unsigned char *b
7485:
+7486: 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:; } }
+7487: for x in prange(w, schedule='static', num_threads=THREADS):
__pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_r) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_x3) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_3 = __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_9 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_r) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_x2) lastprivate(__pyx_v_x3) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_9; __pyx_t_2++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_r = ((unsigned char *)1); __pyx_v_x2 = ((int)0xbad0bad0); __pyx_v_x3 = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0);
+7488: for y in range(h):
__pyx_t_10 = __pyx_v_h; __pyx_t_11 = __pyx_t_10; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_y = __pyx_t_12;
7489:
+7490: r = &rgb_array_copy[x, y, 0]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_13 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_copy.strides[2]) ))));
+7491: g = &rgb_array_copy[x, y, 1]
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_15 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_copy.strides[2]) ))));
+7492: b = &rgb_array_copy[x, y, 2]
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_copy.data + __pyx_t_13 * __pyx_v_rgb_array_copy.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_copy.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_copy.strides[2]) ))));
7493:
+7494: x2 = x >> 1
__pyx_v_x2 = (__pyx_v_x >> 1);
+7495: rgb_array_[x2, y, 0] = r[0]
__pyx_t_15 = __pyx_v_x2; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_r[0]);
+7496: rgb_array_[x2, y, 1] = g[0]
__pyx_t_13 = __pyx_v_x2; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_g[0]);
+7497: rgb_array_[x2, y, 2] = b[0]
__pyx_t_15 = __pyx_v_x2; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_b[0]);
7498:
+7499: x3 = <int>w - x2 - 1
__pyx_v_x3 = ((((int)__pyx_v_w) - __pyx_v_x2) - 1);
7500:
+7501: rgb_array_[x3, y, 0] = r[0]
__pyx_t_13 = __pyx_v_x3; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_r[0]);
+7502: rgb_array_[x3, y, 1] = g[0]
__pyx_t_15 = __pyx_v_x3; __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_g[0]);
+7503: rgb_array_[x3, y, 2] = b[0]
__pyx_t_13 = __pyx_v_x3; __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = (__pyx_v_b[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 }
7504:
7505:
7506: @cython.boundscheck(False)
7507: @cython.wraparound(False)
7508: @cython.nonecheck(False)
7509: @cython.cdivision(True)
+7510: cpdef tuple dampening(
static PyObject *__pyx_pw_6shader_161dampening(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_6shader_dampening(PyObject *__pyx_v_surface_, int __pyx_v_frame_, int __pyx_v_display_width, int __pyx_v_display_height_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_dampening *__pyx_optional_args) { float __pyx_v_amplitude_ = ((float)50.0); int __pyx_v_duration_ = ((int)30); float __pyx_v_freq_ = ((float)20.0); float __pyx_v_t; int __pyx_v_width; int __pyx_v_height; float __pyx_v_tm; PyObject *__pyx_v_surf = 0; int __pyx_v_new_width; int __pyx_v_new_height; int __pyx_v_diff_x; int __pyx_v_diff_y; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dampening", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_amplitude_ = __pyx_optional_args->amplitude_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_duration_ = __pyx_optional_args->duration_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_freq_ = __pyx_optional_args->freq_; } } } } /* … */ /* 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_9); __Pyx_AddTraceback("shader.dampening", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_surf); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_161dampening(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_160dampening[] = "\n DAMPENING EFFECT\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n Compatible with image 24-32 bit\n The length of the effect equal duration_ * freq_\n\n e.g :\n surf, xx, yy = dampening(BCK, frame, width, height,\n amplitude_=100, duration_=40, freq_=15)\n SCREEN.blit(surf, (xx, yy))\n\n :param surface_ : pygame.Surface (compatible 24 - 32 bit)\n :param frame_ : integer; Frame number (linear variable changing overtime)\n :param display_width : integer; Size of your game display (width)\n :param display_height_: integer; size of your game display (height)\n :param amplitude_ : float; Amplitude of the dampening effect (default is 50)\n :param duration_ : integer; Duration of the effect (default value is 30)\n :param freq_ : float; change the speed of the effect default value is 20.0.\n A small value will decrease\n the overall timing of the effect while a larger value will increase the duration of the effect.\n :return : Tuple values containing the Surface and the position (x, y)\n with x & y are the top\n left corner of the\n image\n "; static PyObject *__pyx_pw_6shader_161dampening(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_surface_ = 0; int __pyx_v_frame_; int __pyx_v_display_width; int __pyx_v_display_height_; float __pyx_v_amplitude_; int __pyx_v_duration_; float __pyx_v_freq_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dampening (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_surface,&__pyx_n_s_frame_2,&__pyx_n_s_display_width,&__pyx_n_s_display_height,&__pyx_n_s_amplitude,&__pyx_n_s_duration,&__pyx_n_s_freq,0}; PyObject* values[7] = {0,0,0,0,0,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 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; 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_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_frame_2)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("dampening", 0, 4, 7, 1); __PYX_ERR(1, 7510, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_display_width)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("dampening", 0, 4, 7, 2); __PYX_ERR(1, 7510, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_display_height)) != 0)) kw_args--; else { __Pyx_RaiseArgtupleInvalid("dampening", 0, 4, 7, 3); __PYX_ERR(1, 7510, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_amplitude); if (value) { values[4] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_duration); if (value) { values[5] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_freq); if (value) { values[6] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "dampening") < 0)) __PYX_ERR(1, 7510, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); values[2] = PyTuple_GET_ITEM(__pyx_args, 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_surface_ = values[0]; __pyx_v_frame_ = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_frame_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7512, __pyx_L3_error) __pyx_v_display_width = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_display_width == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7513, __pyx_L3_error) __pyx_v_display_height_ = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_display_height_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7514, __pyx_L3_error) if (values[4]) { __pyx_v_amplitude_ = __pyx_PyFloat_AsFloat(values[4]); if (unlikely((__pyx_v_amplitude_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 7515, __pyx_L3_error) } else { __pyx_v_amplitude_ = ((float)50.0); } if (values[5]) { __pyx_v_duration_ = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_duration_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7516, __pyx_L3_error) } else { __pyx_v_duration_ = ((int)30); } if (values[6]) { __pyx_v_freq_ = __pyx_PyFloat_AsFloat(values[6]); if (unlikely((__pyx_v_freq_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 7517, __pyx_L3_error) } else { __pyx_v_freq_ = ((float)20.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dampening", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 7510, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.dampening", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_160dampening(__pyx_self, __pyx_v_surface_, __pyx_v_frame_, __pyx_v_display_width, __pyx_v_display_height_, __pyx_v_amplitude_, __pyx_v_duration_, __pyx_v_freq_); 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_6shader_160dampening(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_surface_, int __pyx_v_frame_, int __pyx_v_display_width, int __pyx_v_display_height_, float __pyx_v_amplitude_, int __pyx_v_duration_, float __pyx_v_freq_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dampening", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 3; __pyx_t_2.amplitude_ = __pyx_v_amplitude_; __pyx_t_2.duration_ = __pyx_v_duration_; __pyx_t_2.freq_ = __pyx_v_freq_; __pyx_t_1 = __pyx_f_6shader_dampening(__pyx_v_surface_, __pyx_v_frame_, __pyx_v_display_width, __pyx_v_display_height_, 0, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7510, __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("shader.dampening", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7511: object surface_,
7512: int frame_,
7513: int display_width,
7514: int display_height_,
7515: float amplitude_=50.0,
7516: int duration_=30,
7517: float freq_=20.0):
7518:
7519: """
7520: DAMPENING EFFECT
7521:
7522: Cython cpdef function, this function can be called directly and do not require a
7523: hook function.
7524:
7525: Compatible with image 24-32 bit
7526: The length of the effect equal duration_ * freq_
7527:
7528: e.g :
7529: surf, xx, yy = dampening(BCK, frame, width, height,
7530: amplitude_=100, duration_=40, freq_=15)
7531: SCREEN.blit(surf, (xx, yy))
7532:
7533: :param surface_ : pygame.Surface (compatible 24 - 32 bit)
7534: :param frame_ : integer; Frame number (linear variable changing overtime)
7535: :param display_width : integer; Size of your game display (width)
7536: :param display_height_: integer; size of your game display (height)
7537: :param amplitude_ : float; Amplitude of the dampening effect (default is 50)
7538: :param duration_ : integer; Duration of the effect (default value is 30)
7539: :param freq_ : float; change the speed of the effect default value is 20.0.
7540: A small value will decrease
7541: the overall timing of the effect while a larger value will increase the duration of the effect.
7542: :return : Tuple values containing the Surface and the position (x, y)
7543: with x & y are the top
7544: left corner of the
7545: image
7546: """
7547:
+7548: assert freq_ > 0.0, "Argument freq_ must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_freq_ > 0.0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_freq__must_be_0); __PYX_ERR(1, 7548, __pyx_L1_error) } } #endif
+7549: assert duration_ > 0.0, "Argument duration_ must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_duration_ > 0.0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_duration__must_be_0); __PYX_ERR(1, 7549, __pyx_L1_error) } } #endif
7550:
+7551: cdef float t = damped_oscillation((frame_ / freq_) % duration_)
__pyx_v_t = __pyx_f_6shader_damped_oscillation(fmodf((__pyx_v_frame_ / __pyx_v_freq_), __pyx_v_duration_));
7552: cdef int width, height,
+7553: cdef float tm = t * amplitude_
__pyx_v_tm = (__pyx_v_t * __pyx_v_amplitude_);
7554:
+7555: width, height = surface_.get_size()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_get_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 7555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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(1, 7555, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #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(1, 7555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(1, 7555, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 7555, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7555, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7555, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_width = __pyx_t_6; __pyx_v_height = __pyx_t_7;
7556:
+7557: if width + tm < 0:
__pyx_t_8 = (((__pyx_v_width + __pyx_v_tm) < 0.0) != 0); if (__pyx_t_8) { /* … */ }
+7558: tm = 0
__pyx_v_tm = 0.0;
+7559: if height + tm < 0:
__pyx_t_8 = (((__pyx_v_height + __pyx_v_tm) < 0.0) != 0); if (__pyx_t_8) { /* … */ }
+7560: tm = 0
__pyx_v_tm = 0.0;
+7561: cdef object surf = smoothscale(surface_, (<int>tm +<int> (width + <int>tm),
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_smoothscale); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_int((((int)__pyx_v_tm) + ((int)(__pyx_v_width + ((int)__pyx_v_tm))))); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_surface_, __pyx_t_9}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_surface_, __pyx_t_9}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else #endif { __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_v_surface_); __Pyx_GIVEREF(__pyx_v_surface_); PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_surface_); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_surf = __pyx_t_1; __pyx_t_1 = 0;
+7562: <int>tm +<int> (height + <int>tm)))
__pyx_t_4 = __Pyx_PyInt_From_int((((int)__pyx_v_tm) + ((int)(__pyx_v_height + ((int)__pyx_v_tm))))); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
7563: cdef int new_width, new_height
+7564: new_width, new_height = surf.get_size()
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_surf, __pyx_n_s_get_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 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(1, 7564, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = Py_TYPE(__pyx_t_9)->tp_iternext; index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_9); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_9); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_9), 2) < 0) __PYX_ERR(1, 7564, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(1, 7564, __pyx_L1_error) __pyx_L8_unpacking_done:; } __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7564, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_new_width = __pyx_t_7; __pyx_v_new_height = __pyx_t_6;
7565:
+7566: cdef int diff_x = display_width - new_width
__pyx_v_diff_x = (__pyx_v_display_width - __pyx_v_new_width);
+7567: cdef int diff_y = display_height_ - new_height
__pyx_v_diff_y = (__pyx_v_display_height_ - __pyx_v_new_height);
7568:
+7569: return surf, diff_x >> 1, diff_y >> 1
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_diff_x >> 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_diff_y >> 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_surf); __Pyx_GIVEREF(__pyx_v_surf); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_surf); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0;
7570:
7571:
7572: @cython.boundscheck(False)
7573: @cython.wraparound(False)
7574: @cython.nonecheck(False)
7575: @cython.cdivision(False)
+7576: cpdef inline float lateral_dampening(int frame_, float amplitude_=50.0,
static PyObject *__pyx_pw_6shader_163lateral_dampening(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static CYTHON_INLINE float __pyx_f_6shader_lateral_dampening(int __pyx_v_frame_, CYTHON_UNUSED int __pyx_skip_dispatch, struct __pyx_opt_args_6shader_lateral_dampening *__pyx_optional_args) { float __pyx_v_amplitude_ = ((float)50.0); int __pyx_v_duration_ = ((int)30); float __pyx_v_freq_ = ((float)20.0); float __pyx_v_t; float __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lateral_dampening", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_amplitude_ = __pyx_optional_args->amplitude_; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_duration_ = __pyx_optional_args->duration_; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_freq_ = __pyx_optional_args->freq_; } } } } /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_WriteUnraisable("shader.lateral_dampening", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_6shader_163lateral_dampening(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_6shader_162lateral_dampening[] = "\n DAMPENING EFFECT\n\n * This method return the lateral displacement (x)\n\n e.g:\n tm = lateral_dampening(frame, amplitude_=50.0, duration_=35, freq_=5.0)\n SCREEN.blit(BCK, (tm, 0), special_flags=0)\n\n Cython cpdef function, this function can be called directly and do not require a\n hook function.\n\n The length of the effect equal duration_ * freq_\n\n :param frame_ : integer; Your game frame number\n :param amplitude_: float; Represent the amplitude of the dampening effect.\n An amplitude of 1.0 will have no effect.Default value is 50.0\n :param duration_ : float; This represent the duration of the effect, default value is 30\n :param freq_ : float; change the speed of the effect default value is 20.0.\n A small value will decrease\n the overall timing of the effect while a larger value will increase the \n duration of the effect.\n :return : Return a float corresponding to the lateral displacement (x)\n "; static PyObject *__pyx_pw_6shader_163lateral_dampening(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_v_frame_; float __pyx_v_amplitude_; int __pyx_v_duration_; float __pyx_v_freq_; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lateral_dampening (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_frame_2,&__pyx_n_s_amplitude,&__pyx_n_s_duration,&__pyx_n_s_freq,0}; PyObject* values[4] = {0,0,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 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_frame_2)) != 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_amplitude); 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_duration); 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_freq); if (value) { values[3] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lateral_dampening") < 0)) __PYX_ERR(1, 7576, __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); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_frame_ = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_frame_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7576, __pyx_L3_error) if (values[1]) { __pyx_v_amplitude_ = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_amplitude_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 7576, __pyx_L3_error) } else { __pyx_v_amplitude_ = ((float)50.0); } if (values[2]) { __pyx_v_duration_ = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_duration_ == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 7577, __pyx_L3_error) } else { __pyx_v_duration_ = ((int)30); } if (values[3]) { __pyx_v_freq_ = __pyx_PyFloat_AsFloat(values[3]); if (unlikely((__pyx_v_freq_ == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 7577, __pyx_L3_error) } else { __pyx_v_freq_ = ((float)20.0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("lateral_dampening", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 7576, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("shader.lateral_dampening", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6shader_162lateral_dampening(__pyx_self, __pyx_v_frame_, __pyx_v_amplitude_, __pyx_v_duration_, __pyx_v_freq_); 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_6shader_162lateral_dampening(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_frame_, float __pyx_v_amplitude_, int __pyx_v_duration_, float __pyx_v_freq_) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("lateral_dampening", 0); __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 3; __pyx_t_2.amplitude_ = __pyx_v_amplitude_; __pyx_t_2.duration_ = __pyx_v_duration_; __pyx_t_2.freq_ = __pyx_v_freq_; __pyx_t_1 = __pyx_f_6shader_lateral_dampening(__pyx_v_frame_, 0, &__pyx_t_2); __pyx_t_3 = PyFloat_FromDouble(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("shader.lateral_dampening", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7577: int duration_=30, float freq_=20.0):
7578: """
7579: DAMPENING EFFECT
7580:
7581: * This method return the lateral displacement (x)
7582:
7583: e.g:
7584: tm = lateral_dampening(frame, amplitude_=50.0, duration_=35, freq_=5.0)
7585: SCREEN.blit(BCK, (tm, 0), special_flags=0)
7586:
7587: Cython cpdef function, this function can be called directly and do not require a
7588: hook function.
7589:
7590: The length of the effect equal duration_ * freq_
7591:
7592: :param frame_ : integer; Your game frame number
7593: :param amplitude_: float; Represent the amplitude of the dampening effect.
7594: An amplitude of 1.0 will have no effect.Default value is 50.0
7595: :param duration_ : float; This represent the duration of the effect, default value is 30
7596: :param freq_ : float; change the speed of the effect default value is 20.0.
7597: A small value will decrease
7598: the overall timing of the effect while a larger value will increase the
7599: duration of the effect.
7600: :return : Return a float corresponding to the lateral displacement (x)
7601: """
+7602: assert freq_ > 0, "Argument freq_ must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_freq_ > 0.0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_freq__must_be_0); __PYX_ERR(1, 7602, __pyx_L1_error) } } #endif
+7603: assert duration_ > 0, "Argument duration_ must be > 0"
#ifndef CYTHON_WITHOUT_ASSERTIONS if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_duration_ > 0) != 0))) { PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Argument_duration__must_be_0); __PYX_ERR(1, 7603, __pyx_L1_error) } } #endif
7604:
+7605: cdef float t = damped_oscillation((<float>frame_ / freq_) % duration_) * amplitude_
if (unlikely(__pyx_v_freq_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(1, 7605, __pyx_L1_error) } __pyx_t_1 = (((float)__pyx_v_frame_) / __pyx_v_freq_); if (unlikely(__pyx_v_duration_ == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float divmod()"); __PYX_ERR(1, 7605, __pyx_L1_error) } __pyx_v_t = (__pyx_f_6shader_damped_oscillation(__Pyx_mod_float(__pyx_t_1, __pyx_v_duration_)) * __pyx_v_amplitude_);
+7606: return t
__pyx_r = __pyx_v_t; goto __pyx_L0;
7607:
7608: # --------------------------------------------------------------------------------------------------------
7609: # KERNEL DEFINITION FOR SHARPEN ALGORITHM
+7610: cdef float [:, :] SHARPEN_KERNEL = numpy.array(([0, -1, 0],
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array_2); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 7610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_0); /* … */ __pyx_t_30 = PyTuple_New(3); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 7610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_30, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_33); __Pyx_GIVEREF(__pyx_t_31); PyTuple_SET_ITEM(__pyx_t_30, 2, __pyx_t_31); __pyx_t_2 = 0; __pyx_t_33 = 0; __pyx_t_31 = 0; __pyx_t_31 = __Pyx_PyObject_CallOneArg(__pyx_t_32, __pyx_t_30); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 7610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
+7611: [-1, 5, -1],
__pyx_t_33 = PyList_New(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_33, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_5); __Pyx_GIVEREF(__pyx_int_5); PyList_SET_ITEM(__pyx_t_33, 1, __pyx_int_5); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_33, 2, __pyx_int_neg_1);
+7612: [0, -1, 0])).astype(dtype=float32)
__pyx_t_31 = PyList_New(3); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_31, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_31, 1, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_31, 2, __pyx_int_0); /* … */ __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_31, __pyx_n_s_astype); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0; __pyx_t_31 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_n_s_float32); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); if (PyDict_SetItem(__pyx_t_31, __pyx_n_s_dtype, __pyx_t_32) < 0) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_30, __pyx_empty_tuple, __pyx_t_31); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0; __pyx_t_34 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_32, PyBUF_WRITABLE); if (unlikely(!__pyx_t_34.memview)) __PYX_ERR(1, 7612, __pyx_L1_error) __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; __PYX_XDEC_MEMVIEW(&__pyx_v_6shader_SHARPEN_KERNEL, 1); __pyx_v_6shader_SHARPEN_KERNEL = __pyx_t_34; __pyx_t_34.memview = NULL; __pyx_t_34.data = NULL;
+7613: cdef int HALF_KERNEL = len(SHARPEN_KERNEL) >> 1
if (unlikely(!__pyx_v_6shader_SHARPEN_KERNEL.memview)) { __Pyx_RaiseUnboundLocalError("SHARPEN_KERNEL"); __PYX_ERR(1, 7613, __pyx_L1_error) } __pyx_t_47 = __Pyx_MemoryView_Len(__pyx_v_6shader_SHARPEN_KERNEL); __pyx_v_6shader_HALF_KERNEL = (__pyx_t_47 >> 1);
7614:
7615: @cython.boundscheck(False)
7616: @cython.wraparound(False)
7617: @cython.nonecheck(False)
7618: @cython.cdivision(True)
+7619: cdef inline void shader_sharpen_filter_inplace_c(unsigned char [:, :, :] rgb_array_):
static CYTHON_INLINE void __pyx_f_6shader_shader_sharpen_filter_inplace_c(__Pyx_memviewslice __pyx_v_rgb_array_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_rgb_array_1 = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; short __pyx_v_kernel_offset_y; short __pyx_v_kernel_offset_x; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; float __pyx_v_k; unsigned char *__pyx_v_rr; unsigned char *__pyx_v_gg; unsigned char *__pyx_v_bb; int __pyx_v_w_1; int __pyx_v_h_1; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("shader_sharpen_filter_inplace_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_WriteUnraisable("shader.shader_sharpen_filter_inplace_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_rgb_array_1, 1); __Pyx_RefNannyFinishContext(); }
7620: """
7621: SHARPEN IMAGE APPLYING THE BELOW 3 X 3 KERNEL OVER EVERY PIXELS.
7622:
7623: The Array (rgb_array) must be a numpy array shape (w, h, 3)
7624: containing RGB pixels, please refer to pygame
7625: function pixels3d or array3d to convert an image into a 3d array (library surfarray)
7626:
7627: pixels convoluted outside image edges will be set to adjacent edge value
7628: [0 , -1, 0]
7629: [-1, 5, -1]
7630: [0 , -1, 0]
7631:
7632: e.g
7633: sharpen(surface_)
7634:
7635: :param rgb_array_: numpy.ndarray shape (w, h, 3) containing all the RGB pixels
7636: :return : void
7637: """
7638:
7639: # texture sizes
7640: cdef Py_ssize_t w, h
+7641: w, h = rgb_array_.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array_.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
7642:
7643: cdef:
7644:
+7645: unsigned char [:, :, :] rgb_array_1 = numpy.empty((w, h, 3), uint8)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_numpy); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_3); __pyx_t_5 = 0; __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_uint8); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(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_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_8, __pyx_t_7}; __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_8, __pyx_t_7}; __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else #endif { __pyx_t_10 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_9, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_9, __pyx_t_7); __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 7645, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_rgb_array_1 = __pyx_t_11; __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
7646: int x, y, xx, yy
7647: short kernel_offset_y, kernel_offset_x
7648: float r, g, b, k
7649: unsigned char *rr
7650: unsigned char *gg
7651: unsigned char *bb
+7652: int w_1 = <int>w - 1
__pyx_v_w_1 = (((int)__pyx_v_w) - 1);
+7653: int h_1 = <int>h - 1
__pyx_v_h_1 = (((int)__pyx_v_h) - 1);
7654:
+7655: 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_L4_error: { #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L1_error; } __pyx_L5:; } }
7656:
+7657: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_12 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_12; __pyx_t_2++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_bb = ((unsigned char *)1); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_gg = ((unsigned char *)1); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset_x = ((short)0xbad0bad0); __pyx_v_kernel_offset_y = ((short)0xbad0bad0); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_rr = ((unsigned char *)1); __pyx_v_x = ((int)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
7658:
+7659: for x in range(w):
__pyx_t_13 = __pyx_v_w; __pyx_t_14 = __pyx_t_13; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_14; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
7660:
+7661: rr = &rgb_array_1[x, y, 0]
__pyx_t_15 = __pyx_v_x; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 0; __pyx_v_rr = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_1.data + __pyx_t_15 * __pyx_v_rgb_array_1.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_1.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb_array_1.strides[2]) ))));
+7662: gg = &rgb_array_1[x, y, 1]
__pyx_t_17 = __pyx_v_x; __pyx_t_16 = __pyx_v_y; __pyx_t_15 = 1; __pyx_v_gg = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_1.data + __pyx_t_17 * __pyx_v_rgb_array_1.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_1.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_1.strides[2]) ))));
+7663: bb = &rgb_array_1[x, y, 2]
__pyx_t_15 = __pyx_v_x; __pyx_t_16 = __pyx_v_y; __pyx_t_17 = 2; __pyx_v_bb = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_1.data + __pyx_t_15 * __pyx_v_rgb_array_1.strides[0]) ) + __pyx_t_16 * __pyx_v_rgb_array_1.strides[1]) ) + __pyx_t_17 * __pyx_v_rgb_array_1.strides[2]) ))));
7664:
+7665: r, g, b = 0, 0, 0
__pyx_t_18 = 0.0; __pyx_t_19 = 0.0; __pyx_t_20 = 0.0; __pyx_v_r = __pyx_t_18; __pyx_v_g = __pyx_t_19; __pyx_v_b = __pyx_t_20;
7666:
+7667: for kernel_offset_y in range(-HALF_KERNEL, HALF_KERNEL + 1):
__pyx_t_21 = (__pyx_v_6shader_HALF_KERNEL + 1); __pyx_t_22 = __pyx_t_21; for (__pyx_t_23 = (-__pyx_v_6shader_HALF_KERNEL); __pyx_t_23 < __pyx_t_22; __pyx_t_23+=1) { __pyx_v_kernel_offset_y = __pyx_t_23;
7668:
+7669: for kernel_offset_x in range(-HALF_KERNEL, HALF_KERNEL + 1):
__pyx_t_24 = (__pyx_v_6shader_HALF_KERNEL + 1); __pyx_t_25 = __pyx_t_24; for (__pyx_t_26 = (-__pyx_v_6shader_HALF_KERNEL); __pyx_t_26 < __pyx_t_25; __pyx_t_26+=1) { __pyx_v_kernel_offset_x = __pyx_t_26;
7670:
+7671: xx = x + kernel_offset_x
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset_x);
+7672: yy = y + kernel_offset_y
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset_y);
7673:
+7674: if xx < 0:
__pyx_t_27 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_27) { /* … */ goto __pyx_L16; }
+7675: xx = 0
__pyx_v_xx = 0;
+7676: elif xx > w_1:
__pyx_t_27 = ((__pyx_v_xx > __pyx_v_w_1) != 0); if (__pyx_t_27) { /* … */ } __pyx_L16:;
+7677: xx = w_1
__pyx_v_xx = __pyx_v_w_1;
7678:
+7679: if yy < 0:
__pyx_t_27 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_27) { /* … */ goto __pyx_L17; }
+7680: yy = 0
__pyx_v_yy = 0;
+7681: elif yy > h_1:
__pyx_t_27 = ((__pyx_v_yy > __pyx_v_h_1) != 0); if (__pyx_t_27) { /* … */ } __pyx_L17:;
+7682: yy = h_1
__pyx_v_yy = __pyx_v_h_1;
7683:
+7684: k = SHARPEN_KERNEL[kernel_offset_y + HALF_KERNEL,
if (unlikely(!__pyx_v_6shader_SHARPEN_KERNEL.memview)) { __Pyx_RaiseUnboundMemoryviewSliceNogil("SHARPEN_KERNEL"); __PYX_ERR(1, 7684, __pyx_L8_error) } /* … */ __pyx_t_17 = (__pyx_v_kernel_offset_y + __pyx_v_6shader_HALF_KERNEL); __pyx_t_16 = (__pyx_v_kernel_offset_x + __pyx_v_6shader_HALF_KERNEL); __pyx_v_k = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_6shader_SHARPEN_KERNEL.data + __pyx_t_17 * __pyx_v_6shader_SHARPEN_KERNEL.strides[0]) ) + __pyx_t_16 * __pyx_v_6shader_SHARPEN_KERNEL.strides[1]) )));
7685: kernel_offset_x + HALF_KERNEL]
7686:
+7687: r = r + rgb_array_[xx, yy, 0] * k
__pyx_t_16 = __pyx_v_xx; __pyx_t_17 = __pyx_v_yy; __pyx_t_15 = 0; __pyx_v_r = (__pyx_v_r + ((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))) * __pyx_v_k));
+7688: g = g + rgb_array_[xx, yy, 1] * k
__pyx_t_15 = __pyx_v_xx; __pyx_t_17 = __pyx_v_yy; __pyx_t_16 = 1; __pyx_v_g = (__pyx_v_g + ((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_.strides[2]) ))) * __pyx_v_k));
+7689: b = b + rgb_array_[xx, yy, 2] * k
__pyx_t_16 = __pyx_v_xx; __pyx_t_17 = __pyx_v_yy; __pyx_t_15 = 2; __pyx_v_b = (__pyx_v_b + ((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_16 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) ))) * __pyx_v_k)); } }
7690:
+7691: if r < 0:
__pyx_t_27 = ((__pyx_v_r < 0.0) != 0); if (__pyx_t_27) { /* … */ }
+7692: r = 0
__pyx_v_r = 0.0;
+7693: if g < 0:
__pyx_t_27 = ((__pyx_v_g < 0.0) != 0); if (__pyx_t_27) { /* … */ }
+7694: g = 0
__pyx_v_g = 0.0;
+7695: if b < 0:
__pyx_t_27 = ((__pyx_v_b < 0.0) != 0); if (__pyx_t_27) { /* … */ }
+7696: b = 0
__pyx_v_b = 0.0;
+7697: if r > 255:
__pyx_t_27 = ((__pyx_v_r > 255.0) != 0); if (__pyx_t_27) { /* … */ }
+7698: r= 255
__pyx_v_r = 255.0;
+7699: if g > 255:
__pyx_t_27 = ((__pyx_v_g > 255.0) != 0); if (__pyx_t_27) { /* … */ }
+7700: g = 255
__pyx_v_g = 255.0;
+7701: if b > 255:
__pyx_t_27 = ((__pyx_v_b > 255.0) != 0); if (__pyx_t_27) { /* … */ }
+7702: b = 255
__pyx_v_b = 255.0;
7703:
+7704: rr[0] = <unsigned char>r
(__pyx_v_rr[0]) = ((unsigned char)__pyx_v_r);
+7705: gg[0] = <unsigned char>g
(__pyx_v_gg[0]) = ((unsigned char)__pyx_v_g);
+7706: bb[0] = <unsigned char>b
(__pyx_v_bb[0]) = ((unsigned char)__pyx_v_b); } goto __pyx_L25; __pyx_L8_error:; { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #ifdef _OPENMP #pragma omp flush(__pyx_parallel_exc_type) #endif /* _OPENMP */ if (!__pyx_parallel_exc_type) { __Pyx_ErrFetchWithState(&__pyx_parallel_exc_type, &__pyx_parallel_exc_value, &__pyx_parallel_exc_tb); __pyx_parallel_filename = __pyx_filename; __pyx_parallel_lineno = __pyx_lineno; __pyx_parallel_clineno = __pyx_clineno; __Pyx_GOTREF(__pyx_parallel_exc_type); } #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } __pyx_parallel_why = 4; goto __pyx_L24; __pyx_L24:; #ifdef _OPENMP #pragma omp critical(__pyx_parallel_lastprivates13) #endif /* _OPENMP */ { __pyx_parallel_temp0 = __pyx_v_b; __pyx_parallel_temp1 = __pyx_v_bb; __pyx_parallel_temp2 = __pyx_v_g; __pyx_parallel_temp3 = __pyx_v_gg; __pyx_parallel_temp4 = __pyx_v_k; __pyx_parallel_temp5 = __pyx_v_kernel_offset_x; __pyx_parallel_temp6 = __pyx_v_kernel_offset_y; __pyx_parallel_temp7 = __pyx_v_r; __pyx_parallel_temp8 = __pyx_v_rr; __pyx_parallel_temp9 = __pyx_v_x; __pyx_parallel_temp10 = __pyx_v_xx; __pyx_parallel_temp11 = __pyx_v_y; __pyx_parallel_temp12 = __pyx_v_yy; } __pyx_L25:; #ifdef _OPENMP #pragma omp flush(__pyx_parallel_why) #endif /* _OPENMP */ } } #ifdef _OPENMP Py_END_ALLOW_THREADS #else { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif #endif /* _OPENMP */ /* Clean up any temporaries */ #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif #ifndef _OPENMP } #endif /* _OPENMP */ } } if (__pyx_parallel_exc_type) { /* This may have been overridden by a continue, break or return in another thread. Prefer the error. */ __pyx_parallel_why = 4; } if (__pyx_parallel_why) { __pyx_v_b = __pyx_parallel_temp0; __pyx_v_bb = __pyx_parallel_temp1; __pyx_v_g = __pyx_parallel_temp2; __pyx_v_gg = __pyx_parallel_temp3; __pyx_v_k = __pyx_parallel_temp4; __pyx_v_kernel_offset_x = __pyx_parallel_temp5; __pyx_v_kernel_offset_y = __pyx_parallel_temp6; __pyx_v_r = __pyx_parallel_temp7; __pyx_v_rr = __pyx_parallel_temp8; __pyx_v_x = __pyx_parallel_temp9; __pyx_v_xx = __pyx_parallel_temp10; __pyx_v_y = __pyx_parallel_temp11; __pyx_v_yy = __pyx_parallel_temp12; switch (__pyx_parallel_why) { case 4: { #ifdef WITH_THREAD PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); #endif __Pyx_GIVEREF(__pyx_parallel_exc_type); __Pyx_ErrRestoreWithState(__pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb); __pyx_filename = __pyx_parallel_filename; __pyx_lineno = __pyx_parallel_lineno; __pyx_clineno = __pyx_parallel_clineno; #ifdef WITH_THREAD __Pyx_PyGILState_Release(__pyx_gilstate_save); #endif } goto __pyx_L4_error; } } } #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
7707:
+7708: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_12 = __pyx_v_h; 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_12 - 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_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_12 = __pyx_v_h; 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_12 - 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_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_x = ((int)0xbad0bad0);
7709:
+7710: for x in range(w):
__pyx_t_13 = __pyx_v_w; __pyx_t_14 = __pyx_t_13; for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_14; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
+7711: rgb_array_[x, y, 0] = rgb_array_1[x, y, 0]
__pyx_t_15 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_16 = 0; __pyx_t_28 = __pyx_v_x; __pyx_t_29 = __pyx_v_y; __pyx_t_30 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_28 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_29 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_30 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_1.data + __pyx_t_15 * __pyx_v_rgb_array_1.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_1.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_1.strides[2]) )));
+7712: rgb_array_[x, y, 1] = rgb_array_1[x, y, 1]
__pyx_t_16 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_15 = 1; __pyx_t_30 = __pyx_v_x; __pyx_t_29 = __pyx_v_y; __pyx_t_28 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_30 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_29 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_28 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_1.data + __pyx_t_16 * __pyx_v_rgb_array_1.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_1.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_1.strides[2]) )));
+7713: rgb_array_[x, y, 2] = rgb_array_1[x, y, 2]
__pyx_t_15 = __pyx_v_x; __pyx_t_17 = __pyx_v_y; __pyx_t_16 = 2; __pyx_t_28 = __pyx_v_x; __pyx_t_29 = __pyx_v_y; __pyx_t_30 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_28 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_29 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_30 * __pyx_v_rgb_array_.strides[2]) )) = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_1.data + __pyx_t_15 * __pyx_v_rgb_array_1.strides[0]) ) + __pyx_t_17 * __pyx_v_rgb_array_1.strides[1]) ) + __pyx_t_16 * __pyx_v_rgb_array_1.strides[2]) ))); } } } } } } #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 }
7714:
7715:
7716: # Added to version 1.0.1
7717: @cython.boundscheck(False)
7718: @cython.wraparound(False)
7719: @cython.nonecheck(False)
7720: @cython.cdivision(True)
+7721: cdef cartoon_effect(
static PyObject *__pyx_f_6shader_cartoon_effect(PyObject *__pyx_v_surface_, int __pyx_v_sobel_threshold_, int __pyx_v_median_kernel_, int __pyx_v_color_, int __pyx_v_flag_) { PyObject *__pyx_v_surface_branch_1 = NULL; PyObject *__pyx_v_array_ = NULL; PyObject *__pyx_v_arr = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cartoon_effect", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("shader.cartoon_effect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_surface_branch_1); __Pyx_XDECREF(__pyx_v_array_); __Pyx_XDECREF(__pyx_v_arr); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7722: object surface_,
7723: int sobel_threshold_,
7724: int median_kernel_,
7725: int color_, int flag_):
7726: """
7727:
7728: :param surface_: pygame.Surface compatible 24 - 32 bit
7729: :param sobel_threshold_: integer sobel threshold
7730: :param median_kernel_ : integer median kernel
7731: :param color_ : integer; color reduction value (max color)
7732: :param flag_ : integer; Blend flag e.g (BLEND_RGB_ADD, BLEND_RGB_SUB,
7733: BLEND_RGB_MULT, BLEND_RGB_MAX, BLEND_RGB_MIN
7734: :return : Return a pygame Surface with the cartoon effect
7735: """
7736:
7737: # First branch from the surface_
7738: # surface_branch_1
+7739: surface_branch_1 = surface_.copy()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7739, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__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_1)) __PYX_ERR(1, 7739, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_surface_branch_1 = __pyx_t_1; __pyx_t_1 = 0;
+7740: array_ = canny_blur5x5_surface24_c(surface_branch_1)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_canny_blur5x5_surface24_c); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7740, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_surface_branch_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_surface_branch_1); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7740, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_array_ = __pyx_t_1; __pyx_t_1 = 0;
+7741: shader_greyscale_luminosity24_inplace_c(array_)
__pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(1, 7741, __pyx_L1_error) __pyx_f_6shader_shader_greyscale_luminosity24_inplace_c(__pyx_t_4); __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1); __pyx_t_4.memview = NULL; __pyx_t_4.data = NULL;
+7742: shader_sobel24_inplace_c(array_, sobel_threshold_)
__pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_array_, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(1, 7742, __pyx_L1_error) __pyx_t_5.__pyx_n = 1; __pyx_t_5.threshold = __pyx_v_sobel_threshold_; __pyx_f_6shader_shader_sobel24_inplace_c(__pyx_t_4, &__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1); __pyx_t_4.memview = NULL; __pyx_t_4.data = NULL;
7743:
7744: # Second branch
+7745: arr = pixels3d(surface_)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __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_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_surface_) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_surface_); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_arr = __pyx_t_1; __pyx_t_1 = 0;
+7746: shader_median_filter24_inplace_c(arr, median_kernel_)
__pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_arr, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(1, 7746, __pyx_L1_error) __pyx_t_6.__pyx_n = 1; __pyx_t_6.kernel_size_ = __pyx_v_median_kernel_; __pyx_f_6shader_shader_median_filter24_inplace_c(__pyx_t_4, &__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1); __pyx_t_4.memview = NULL; __pyx_t_4.data = NULL;
7747:
7748: # median_fast(
7749: # surface_,
7750: # kernel_size_=median_kernel_,
7751: # reduce_factor_=2)
7752:
7753: # Color reduction
+7754: shader_color_reduction24_inplace_c(arr, color_)
__pyx_t_4 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_v_arr, PyBUF_WRITABLE); if (unlikely(!__pyx_t_4.memview)) __PYX_ERR(1, 7754, __pyx_L1_error) __pyx_f_6shader_shader_color_reduction24_inplace_c(__pyx_t_4, __pyx_v_color_); __PYX_XDEC_MEMVIEW(&__pyx_t_4, 1); __pyx_t_4.memview = NULL; __pyx_t_4.data = NULL;
7755:
+7756: del arr
__Pyx_DECREF(__pyx_v_arr);
__pyx_v_arr = NULL;
7757:
7758: # Blend both branch
+7759: surface_.blit(make_surface(array_), (0, 0), special_flags=flag_)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_surface_, __pyx_n_s_blit); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_2 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_7, __pyx_v_array_) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_array_); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7759, __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_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_tuple__12); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_flag_); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_special_flags, __pyx_t_7) < 0) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 7759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __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; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7760:
+7761: return surface_
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_surface_); __pyx_r = __pyx_v_surface_; goto __pyx_L0;
7762:
7763:
7764:
7765: # TODO ADD TO TESTING
7766: # Added to version 1.0.1
7767: @cython.boundscheck(False)
7768: @cython.wraparound(False)
7769: @cython.nonecheck(False)
7770: @cython.cdivision(True)
+7771: cdef object blending(object source_, object destination_, float percentage_):
static PyObject *__pyx_f_6shader_blending(PyObject *__pyx_v_source_, PyObject *__pyx_v_destination_, float __pyx_v_percentage_) { __Pyx_memviewslice __pyx_v_source_array = { 0, 0, { 0 }, { 0 }, { 0 } }; __Pyx_memviewslice __pyx_v_destination_array = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_e = NULL; int __pyx_v_c1; int __pyx_v_c2; int __pyx_v_c3; int __pyx_v_i; int __pyx_v_j; Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_final_array = { 0, 0, { 0 }, { 0 }, { 0 } }; float __pyx_v_c4; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("blending", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1); __Pyx_XDECREF(__pyx_t_24); __Pyx_XDECREF(__pyx_t_25); __Pyx_AddTraceback("shader.blending", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_source_array, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_destination_array, 1); __Pyx_XDECREF(__pyx_v_e); __PYX_XDEC_MEMVIEW(&__pyx_v_final_array, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7772: """
7773: BLEND A SOURCE TEXTURE TOWARD A DESTINATION TEXTURE (TRANSITION EFFECT)
7774:
7775: * Video system must be initialised
7776: * source_ & destination_ Textures must be same sizes
7777: * Compatible with 24 - 32 bit surface
7778: * Output create a new surface
7779: * Image returned is converted for fast blit (convert())
7780:
7781: :param source_ : pygame.Surface (Source)
7782: :param destination_: pygame.Surface (Destination)
7783: :param percentage_ : float; Percentage value between [0.0 ... 100.0]
7784: :return: return : Return a 24 bit pygame.Surface and blended with a percentage
7785: of the destination texture.
7786: """
7787:
7788: cdef:
7789: unsigned char [:, :, :] source_array
7790: unsigned char [:, :, :] destination_array
7791:
+7792: 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_L8_try_end; __pyx_L3_error:; __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_XDEC_MEMVIEW(&__pyx_t_7, 1); /* … */ __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_L8_try_end:; }
+7793: source_array = pixels3d(source_)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7793, __pyx_L3_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_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_source_) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_source_); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7793, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_4, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 7793, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_source_array = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
7794:
+7795: except Exception as e:
__pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_8) { __Pyx_AddTraceback("shader.blending", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(1, 7795, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_v_e = __pyx_t_5;
+7796: raise ValueError("\nCannot reference source pixels into a 3d array.\n %s " % e)
__pyx_t_9 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_reference_source_pixels, __pyx_v_e); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7796, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 7796, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(1, 7796, __pyx_L5_except_error) } goto __pyx_L5_except_error; __pyx_L5_except_error:;
7797:
+7798: 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_L16_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 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_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 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_L16_try_end:; }
+7799: destination_array = pixels3d(destination_)
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pixels3d); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7799, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_v_destination_) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_destination_); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7799, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_6, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 7799, __pyx_L11_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_destination_array = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL;
7800:
+7801: except Exception as e:
__pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_8) { __Pyx_AddTraceback("shader.blending", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(1, 7801, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_v_e = __pyx_t_5;
+7802: raise ValueError("\nCannot reference destination pixels into a 3d array.\n %s " % e)
__pyx_t_10 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_reference_destination_pi, __pyx_v_e); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 7802, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7802, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(1, 7802, __pyx_L13_except_error) } goto __pyx_L13_except_error; __pyx_L13_except_error:;
7803:
7804: cdef:
7805:
7806: int c1, c2, c3
+7807: int i=0, j=0
__pyx_v_i = 0; __pyx_v_j = 0;
+7808: Py_ssize_t w = source_array.shape[0]
__pyx_v_w = (__pyx_v_source_array.shape[0]);
+7809: Py_ssize_t h = source_array.shape[1]
__pyx_v_h = (__pyx_v_source_array.shape[1]);
+7810: unsigned char[:, :, ::1] final_array = empty((h, w, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_9, 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(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_uint8); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(1, 7810, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_final_array = __pyx_t_11; __pyx_t_11.memview = NULL; __pyx_t_11.data = NULL;
+7811: float c4 = percentage_ / <float> 100.0
__pyx_v_c4 = (__pyx_v_percentage_ / ((float)100.0));
7812: unsigned char *r
7813: unsigned char *g
7814: unsigned char *b
7815:
+7816: 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_L21; } __pyx_L21:; } }
+7817: for j in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_12 = __pyx_v_h; 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_14 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_14 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_c3) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) /* … */ __pyx_t_12 = __pyx_v_h; 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_14 = (__pyx_t_12 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_14 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_c1) lastprivate(__pyx_v_c2) lastprivate(__pyx_v_c3) lastprivate(__pyx_v_g) lastprivate(__pyx_v_i) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_14; __pyx_t_13++){ { __pyx_v_j = (int)(0 + 1 * __pyx_t_13); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_c1 = ((int)0xbad0bad0); __pyx_v_c2 = ((int)0xbad0bad0); __pyx_v_c3 = ((int)0xbad0bad0); __pyx_v_g = ((unsigned char *)1); __pyx_v_i = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1);
+7818: for i in range(w):
__pyx_t_15 = __pyx_v_w; __pyx_t_16 = __pyx_t_15; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_16; __pyx_t_8+=1) { __pyx_v_i = __pyx_t_8;
7819:
+7820: r = &source_array[i, j, 0]
__pyx_t_17 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_19 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_17 * __pyx_v_source_array.strides[0]) ) + __pyx_t_18 * __pyx_v_source_array.strides[1]) ) + __pyx_t_19 * __pyx_v_source_array.strides[2]) ))));
+7821: g = &source_array[i, j, 1]
__pyx_t_19 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_17 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_19 * __pyx_v_source_array.strides[0]) ) + __pyx_t_18 * __pyx_v_source_array.strides[1]) ) + __pyx_t_17 * __pyx_v_source_array.strides[2]) ))));
+7822: b = &source_array[i, j, 2]
__pyx_t_17 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_19 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_source_array.data + __pyx_t_17 * __pyx_v_source_array.strides[0]) ) + __pyx_t_18 * __pyx_v_source_array.strides[1]) ) + __pyx_t_19 * __pyx_v_source_array.strides[2]) ))));
7823:
+7824: c1 = min(<int> (<float> destination_array[i, j, 0] * c4 +
__pyx_t_20 = 0xFF; __pyx_t_19 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_17 = 0; /* … */ __pyx_t_21 = ((int)((((float)(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_destination_array.data + __pyx_t_19 * __pyx_v_destination_array.strides[0]) ) + __pyx_t_18 * __pyx_v_destination_array.strides[1]) ) + __pyx_t_17 * __pyx_v_destination_array.strides[2]) )))) * __pyx_v_c4) + ((__pyx_v_r[0]) * (((float)1.0) - __pyx_v_c4))));
+7825: r[0] * (<float> 1.0 - c4)), 255)
if (((__pyx_t_20 < __pyx_t_21) != 0)) { __pyx_t_22 = __pyx_t_20; } else { __pyx_t_22 = __pyx_t_21; } __pyx_v_c1 = __pyx_t_22;
+7826: c2 = min(<int> (<float> destination_array[i, j, 1] * c4 +
__pyx_t_22 = 0xFF; __pyx_t_17 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_19 = 1; /* … */ __pyx_t_21 = ((int)((((float)(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_destination_array.data + __pyx_t_17 * __pyx_v_destination_array.strides[0]) ) + __pyx_t_18 * __pyx_v_destination_array.strides[1]) ) + __pyx_t_19 * __pyx_v_destination_array.strides[2]) )))) * __pyx_v_c4) + ((__pyx_v_g[0]) * (((float)1.0) - __pyx_v_c4))));
+7827: g[0] * (<float> 1.0 - c4)), 255)
if (((__pyx_t_22 < __pyx_t_21) != 0)) { __pyx_t_20 = __pyx_t_22; } else { __pyx_t_20 = __pyx_t_21; } __pyx_v_c2 = __pyx_t_20;
+7828: c3 = min(<int> (<float> destination_array[i, j, 2] * c4 +
__pyx_t_20 = 0xFF; __pyx_t_19 = __pyx_v_i; __pyx_t_18 = __pyx_v_j; __pyx_t_17 = 2; /* … */ __pyx_t_21 = ((int)((((float)(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_destination_array.data + __pyx_t_19 * __pyx_v_destination_array.strides[0]) ) + __pyx_t_18 * __pyx_v_destination_array.strides[1]) ) + __pyx_t_17 * __pyx_v_destination_array.strides[2]) )))) * __pyx_v_c4) + ((__pyx_v_b[0]) * (((float)1.0) - __pyx_v_c4))));
+7829: b[0] * (<float> 1.0 - c4)), 255)
if (((__pyx_t_20 < __pyx_t_21) != 0)) { __pyx_t_22 = __pyx_t_20; } else { __pyx_t_22 = __pyx_t_21; } __pyx_v_c3 = __pyx_t_22;
+7830: if c1 < 0:
__pyx_t_23 = ((__pyx_v_c1 < 0) != 0); if (__pyx_t_23) { /* … */ }
+7831: c1 = 0
__pyx_v_c1 = 0;
+7832: if c2 < 0:
__pyx_t_23 = ((__pyx_v_c2 < 0) != 0); if (__pyx_t_23) { /* … */ }
+7833: c2 = 0
__pyx_v_c2 = 0;
+7834: if c3 < 0:
__pyx_t_23 = ((__pyx_v_c3 < 0) != 0); if (__pyx_t_23) { /* … */ }
+7835: c3 = 0
__pyx_v_c3 = 0;
+7836: final_array[j, i, 0] = c1
__pyx_t_17 = __pyx_v_j; __pyx_t_18 = __pyx_v_i; __pyx_t_19 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_final_array.data + __pyx_t_17 * __pyx_v_final_array.strides[0]) ) + __pyx_t_18 * __pyx_v_final_array.strides[1]) )) + __pyx_t_19)) )) = __pyx_v_c1;
+7837: final_array[j, i, 1] = c2
__pyx_t_19 = __pyx_v_j; __pyx_t_18 = __pyx_v_i; __pyx_t_17 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_final_array.data + __pyx_t_19 * __pyx_v_final_array.strides[0]) ) + __pyx_t_18 * __pyx_v_final_array.strides[1]) )) + __pyx_t_17)) )) = __pyx_v_c2;
+7838: final_array[j, i, 2] = c3
__pyx_t_17 = __pyx_v_j; __pyx_t_18 = __pyx_v_i; __pyx_t_19 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_final_array.data + __pyx_t_17 * __pyx_v_final_array.strides[0]) ) + __pyx_t_18 * __pyx_v_final_array.strides[1]) )) + __pyx_t_19)) )) = __pyx_v_c3; } } } } } } #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 }
7839:
+7840: return pygame.image.frombuffer(final_array, (w, h), 'RGB').convert()
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pygame); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_image); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_final_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_24 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_24)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_24); __pyx_t_25 = PyTuple_New(2); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_25); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_25, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_25, 1, __pyx_t_24); __pyx_t_10 = 0; __pyx_t_24 = 0; __pyx_t_24 = NULL; __pyx_t_8 = 0; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_24)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_24); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_24, __pyx_t_4, __pyx_t_25, __pyx_n_s_RGB}; __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[4] = {__pyx_t_24, __pyx_t_4, __pyx_t_25, __pyx_n_s_RGB}; __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0; __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0; } else #endif { __pyx_t_10 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (__pyx_t_24) { __Pyx_GIVEREF(__pyx_t_24); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_24); __pyx_t_24 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_8, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_8, __pyx_t_25); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_10, 2+__pyx_t_8, __pyx_n_s_RGB); __pyx_t_4 = 0; __pyx_t_25 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_convert); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_5 = (__pyx_t_9) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallNoArg(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
7841:
7842:
7843: @cython.boundscheck(False)
7844: @cython.wraparound(False)
7845: @cython.nonecheck(False)
7846: @cython.cdivision(True)
+7847: cdef inline void dirt_lens_c(
static CYTHON_INLINE void __pyx_f_6shader_dirt_lens_c(PyObject *__pyx_v_source_, PyObject *__pyx_v_lens_model_, int __pyx_v_flag_, struct __pyx_opt_args_6shader_dirt_lens_c *__pyx_optional_args) { float __pyx_v_light_ = ((float)0.0); __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dirt_lens_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_light_ = __pyx_optional_args->light_; } } /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_WriteUnraisable("shader.dirt_lens_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); } /* … */ struct __pyx_opt_args_6shader_dirt_lens_c { int __pyx_n; float light_; };
7848: object source_,
7849: object lens_model_,
7850: int flag_,
7851: float light_=0.0):
7852:
+7853: if light_!=0.0:
__pyx_t_1 = ((__pyx_v_light_ != 0.0) != 0); if (__pyx_t_1) { /* … */ }
+7854: brightness(lens_model_, light_)
__pyx_f_6shader_brightness(__pyx_v_lens_model_, __pyx_v_light_, 0);
+7855: source_.blit(lens_model_, (0, 0), special_flags=flag_)
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_source_, __pyx_n_s_blit); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_lens_model_); __Pyx_GIVEREF(__pyx_v_lens_model_); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_lens_model_); __Pyx_INCREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_tuple__12); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_flag_); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_special_flags, __pyx_t_5) < 0) __PYX_ERR(1, 7855, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 7855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7856:
7857:
7858: # TODO DITHERING WITH KERNEL INSTEAD
7859: @cython.boundscheck(False)
7860: @cython.wraparound(False)
7861: @cython.nonecheck(False)
7862: @cython.cdivision(True)
+7863: cdef object dithering_c(float [:, :, :] rgb_array_, int factor_):
static PyObject *__pyx_f_6shader_dithering_c(__Pyx_memviewslice __pyx_v_rgb_array_, int __pyx_v_factor_) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; float __pyx_v_new_red; float __pyx_v_new_green; float __pyx_v_new_blue; float __pyx_v_quantization_error_red; float __pyx_v_quantization_error_green; float __pyx_v_quantization_error_blue; float __pyx_v_oldr; float __pyx_v_oldg; float __pyx_v_oldb; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_AddTraceback("shader.dithering_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
7864:
7865: """
7866: Dithering is used in computer graphics to create the illusion of "color depth" in images with
7867: a limited color palette - a technique also known as color quantization. In a dithered image,
7868: colors that are not available in the palette are approximated by a diffusion of colored pixels
7869: from within the available palette. The human eye perceives the diffusion as a mixture of
7870: the colors within it (see color vision). Dithered images, particularly those with relatively
7871: few colors, can often be distinguished by a characteristic graininess or speckled appearance.
7872:
7873: factor_ represent the color number per RGB channel, values must be (2, 3, 4 .. etc)
7874: and 2 means two colors per channels (2x2x2 = total 8 colors)
7875:
7876:
7877: :param rgb_array_: pygame.Surface compatible 24-32 bit
7878: :param factor_: integer; color per channel; must be > 1.
7879: A value of 2 means a total of 8 colors
7880: :return: pygame surface 24-32 bit
7881: """
7882:
7883: cdef Py_ssize_t w, h
+7884: w = <object> rgb_array_.shape[ 0 ] - 1
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 7884, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_w = __pyx_t_3;
+7885: h = <object> rgb_array_.shape[ 1 ] - 1
__pyx_t_2 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 7885, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_3;
7886:
7887: cdef:
+7888: int x=0, y=0
__pyx_v_x = 0; __pyx_v_y = 0;
7889: float new_red, new_green, new_blue
7890: float quantization_error_red, quantization_error_green, quantization_error_blue
7891: float oldr, oldg, oldb
7892:
+7893: 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:; } }
7894:
+7895: for y in prange(1, h, schedule='static', num_threads=THREADS, chunksize=2**8):
__pyx_t_3 = __pyx_v_h; 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_5 = (__pyx_t_3 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_new_blue) lastprivate(__pyx_v_new_green) lastprivate(__pyx_v_new_red) lastprivate(__pyx_v_oldb) lastprivate(__pyx_v_oldg) lastprivate(__pyx_v_oldr) lastprivate(__pyx_v_quantization_error_blue) lastprivate(__pyx_v_quantization_error_green) lastprivate(__pyx_v_quantization_error_red) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) __pyx_t_6 = __Pyx_pow_long(2, 8); /* … */ __pyx_t_3 = __pyx_v_h; 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_5 = (__pyx_t_3 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_new_blue) lastprivate(__pyx_v_new_green) lastprivate(__pyx_v_new_red) lastprivate(__pyx_v_oldb) lastprivate(__pyx_v_oldg) lastprivate(__pyx_v_oldr) lastprivate(__pyx_v_quantization_error_blue) lastprivate(__pyx_v_quantization_error_green) lastprivate(__pyx_v_quantization_error_red) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static, __pyx_t_6) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4++){ { __pyx_v_y = (int)(1 + 1 * __pyx_t_4); /* Initialize private variables to invalid values */ __pyx_v_new_blue = ((float)__PYX_NAN()); __pyx_v_new_green = ((float)__PYX_NAN()); __pyx_v_new_red = ((float)__PYX_NAN()); __pyx_v_oldb = ((float)__PYX_NAN()); __pyx_v_oldg = ((float)__PYX_NAN()); __pyx_v_oldr = ((float)__PYX_NAN()); __pyx_v_quantization_error_blue = ((float)__PYX_NAN()); __pyx_v_quantization_error_green = ((float)__PYX_NAN()); __pyx_v_quantization_error_red = ((float)__PYX_NAN()); __pyx_v_x = ((int)0xbad0bad0);
7896:
+7897: for x in range(1, w):
__pyx_t_7 = __pyx_v_w; __pyx_t_8 = __pyx_t_7; for (__pyx_t_9 = 1; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
7898:
+7899: oldr = rgb_array_[x, y, 0]
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 0; __pyx_v_oldr = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )));
+7900: oldg = rgb_array_[x, y, 1]
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 1; __pyx_v_oldg = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )));
+7901: oldb = rgb_array_[x, y, 2]
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 2; __pyx_v_oldb = (*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )));
7902:
+7903: new_red = <float>round_c(oldr * (factor_ - 1)) / (factor_ - 1)
__pyx_v_new_red = (((float)round((__pyx_v_oldr * (__pyx_v_factor_ - 1)))) / (__pyx_v_factor_ - 1));
+7904: new_green = <float>round_c(oldg * (factor_ - 1)) / (factor_ - 1)
__pyx_v_new_green = (((float)round((__pyx_v_oldg * (__pyx_v_factor_ - 1)))) / (__pyx_v_factor_ - 1));
+7905: new_blue = <float>round_c(oldb * (factor_ - 1)) / (factor_ - 1)
__pyx_v_new_blue = (((float)round((__pyx_v_oldb * (__pyx_v_factor_ - 1)))) / (__pyx_v_factor_ - 1));
7906:
+7907: rgb_array_[x, y, 0] = new_red
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 0; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_v_new_red;
+7908: rgb_array_[x, y, 1] = new_green
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 1; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_v_new_green;
+7909: rgb_array_[x, y, 2] = new_blue
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 2; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_v_new_blue;
7910:
+7911: quantization_error_red = <float>(oldr - new_red)
__pyx_v_quantization_error_red = ((float)(__pyx_v_oldr - __pyx_v_new_red));
+7912: quantization_error_green = <float>(oldg - new_green)
__pyx_v_quantization_error_green = ((float)(__pyx_v_oldg - __pyx_v_new_green));
+7913: quantization_error_blue = <float>(oldb - new_blue)
__pyx_v_quantization_error_blue = ((float)(__pyx_v_oldb - __pyx_v_new_blue));
7914:
+7915: rgb_array_[x + 1, y, 0] = \
__pyx_t_13 = (__pyx_v_x + 1); __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C1));
+7916: rgb_array_[x + 1, y, 0] + quantization_error_red * C1
__pyx_t_10 = (__pyx_v_x + 1); __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 0;
+7917: rgb_array_[x + 1, y, 1] = \
__pyx_t_15 = (__pyx_v_x + 1); __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C1));
+7918: rgb_array_[x + 1, y, 1] + quantization_error_green * C1
__pyx_t_12 = (__pyx_v_x + 1); __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 1;
+7919: rgb_array_[x + 1, y, 2] = \
__pyx_t_13 = (__pyx_v_x + 1); __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 2; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C1));
+7920: rgb_array_[x + 1, y, 2] + quantization_error_blue * C1
__pyx_t_10 = (__pyx_v_x + 1); __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 2;
7921:
+7922: rgb_array_[x - 1, y + 1, 0] = \
__pyx_t_15 = (__pyx_v_x - 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 0; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C2));
+7923: rgb_array_[x - 1, y + 1, 0] + quantization_error_red * C2
__pyx_t_12 = (__pyx_v_x - 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 0;
+7924: rgb_array_[x - 1, y + 1, 1] = \
__pyx_t_13 = (__pyx_v_x - 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 1; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C2));
+7925: rgb_array_[x - 1, y + 1, 1] + quantization_error_green * C2
__pyx_t_10 = (__pyx_v_x - 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 1;
+7926: rgb_array_[x - 1, y + 1, 2] = \
__pyx_t_15 = (__pyx_v_x - 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 2; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C2));
+7927: rgb_array_[x - 1, y + 1, 2] + quantization_error_blue * C2
__pyx_t_12 = (__pyx_v_x - 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 2;
7928:
+7929: rgb_array_[x, y + 1, 0] = \
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 0; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C3));
+7930: rgb_array_[x, y + 1, 0] + quantization_error_red * C3
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 0;
+7931: rgb_array_[x, y + 1, 1] = \
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 1; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C3));
+7932: rgb_array_[x, y + 1, 1] + quantization_error_green * C3
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 1;
+7933: rgb_array_[x, y + 1, 2] = \
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 2; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C3));
+7934: rgb_array_[x, y + 1, 2] + quantization_error_blue * C3
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 2;
7935:
+7936: rgb_array_[x + 1, y + 1, 0] = \
__pyx_t_15 = (__pyx_v_x + 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 0; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C4));
+7937: rgb_array_[x + 1, y + 1, 0] + quantization_error_red * C4
__pyx_t_12 = (__pyx_v_x + 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 0;
+7938: rgb_array_[x + 1, y + 1, 1] = \
__pyx_t_13 = (__pyx_v_x + 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 1; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C4));
+7939: rgb_array_[x + 1, y + 1, 1] + quantization_error_green * C4
__pyx_t_10 = (__pyx_v_x + 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 1;
+7940: rgb_array_[x + 1, y + 1, 2] = \
__pyx_t_15 = (__pyx_v_x + 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 2; *((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((*((float *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C4)); } } } } } } #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 }
+7941: rgb_array_[x + 1, y + 1, 2] + quantization_error_blue * C4
__pyx_t_12 = (__pyx_v_x + 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 2;
7942:
+7943: return make_surface(numpy.multiply(asarray(rgb_array_), 255.0).astype(dtype=uint8)).convert()
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_numpy); if (unlikely(!__pyx_t_18)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_multiply); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_n_s_asarray); if (unlikely(!__pyx_t_20)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_21 = __pyx_memoryview_fromslice(__pyx_v_rgb_array_, 3, (PyObject *(*)(char *)) __pyx_memview_get_float, (int (*)(char *, PyObject *)) __pyx_memview_set_float, 0);; if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_22 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_20))) { __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_22)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_22); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); } } __pyx_t_18 = (__pyx_t_22) ? __Pyx_PyObject_Call2Args(__pyx_t_20, __pyx_t_22, __pyx_t_21) : __Pyx_PyObject_CallOneArg(__pyx_t_20, __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_18)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = NULL; __pyx_t_9 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) { __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_19); if (likely(__pyx_t_20)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19); __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_19, function); __pyx_t_9 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_19)) { PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_18, __pyx_float_255_0}; __pyx_t_17 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) { PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_18, __pyx_float_255_0}; __pyx_t_17 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } else #endif { __pyx_t_21 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); if (__pyx_t_20) { __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_20); __pyx_t_20 = NULL; } __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_9, __pyx_t_18); __Pyx_INCREF(__pyx_float_255_0); __Pyx_GIVEREF(__pyx_float_255_0); PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_9, __pyx_float_255_0); __pyx_t_18 = 0; __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_21, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_astype); if (unlikely(!__pyx_t_19)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_17 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_n_s_uint8); if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_dtype, __pyx_t_21) < 0) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_empty_tuple, __pyx_t_17); if (unlikely(!__pyx_t_21)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_17 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_2 = (__pyx_t_17) ? __Pyx_PyObject_Call2Args(__pyx_t_16, __pyx_t_17, __pyx_t_21) : __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_21); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_convert); if (unlikely(!__pyx_t_16)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); } } __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_16); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7943, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
7944:
7945:
7946:
7947: @cython.boundscheck(False)
7948: @cython.wraparound(False)
7949: @cython.nonecheck(False)
7950: @cython.cdivision(True)
+7951: cdef inline void dithering_int_c(unsigned char[:, :, :] rgb_array_, int factor_):
static CYTHON_INLINE void __pyx_f_6shader_dithering_int_c(__Pyx_memviewslice __pyx_v_rgb_array_, int __pyx_v_factor_) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; unsigned char __pyx_v_new_red; unsigned char __pyx_v_new_green; unsigned char __pyx_v_new_blue; int __pyx_v_quantization_error_red; int __pyx_v_quantization_error_green; int __pyx_v_quantization_error_blue; unsigned char __pyx_v_oldr; unsigned char __pyx_v_oldg; unsigned char __pyx_v_oldb; float __pyx_v_c5; float __pyx_v_c6; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dithering_int_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("shader.dithering_int_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
7952:
7953:
7954: cdef Py_ssize_t w, h
+7955: w = <object> rgb_array_.shape[ 0 ] - 1
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7955, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7955, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 7955, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_w = __pyx_t_3;
+7956: h = <object> rgb_array_.shape[ 1 ] - 1
__pyx_t_2 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[1])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 7956, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_3;
7957:
7958: cdef:
+7959: int x=0, y=0
__pyx_v_x = 0; __pyx_v_y = 0;
7960: unsigned char new_red, new_green, new_blue
7961: int quantization_error_red, quantization_error_green, quantization_error_blue
7962: unsigned char oldr, oldg, oldb
+7963: float c5 = <float>255.0 / <float>(factor_ -1)
__pyx_v_c5 = (((float)255.0) / ((float)(__pyx_v_factor_ - 1)));
+7964: float c6 = <float>(factor_ -1) * ONE_255
__pyx_v_c6 = (((float)(__pyx_v_factor_ - 1)) * 0.00392156862745098);
7965:
7966:
+7967: 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:; } }
7968:
+7969: for y in prange(1, h, schedule='static', num_threads=THREADS, chunksize=2**8):
__pyx_t_3 = __pyx_v_h; 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_5 = (__pyx_t_3 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_new_blue) lastprivate(__pyx_v_new_green) lastprivate(__pyx_v_new_red) lastprivate(__pyx_v_oldb) lastprivate(__pyx_v_oldg) lastprivate(__pyx_v_oldr) lastprivate(__pyx_v_quantization_error_blue) lastprivate(__pyx_v_quantization_error_green) lastprivate(__pyx_v_quantization_error_red) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) __pyx_t_6 = __Pyx_pow_long(2, 8); /* … */ __pyx_t_3 = __pyx_v_h; 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_5 = (__pyx_t_3 - 1 + 1 - 1/abs(1)) / 1; if (__pyx_t_5 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_new_blue) lastprivate(__pyx_v_new_green) lastprivate(__pyx_v_new_red) lastprivate(__pyx_v_oldb) lastprivate(__pyx_v_oldg) lastprivate(__pyx_v_oldr) lastprivate(__pyx_v_quantization_error_blue) lastprivate(__pyx_v_quantization_error_green) lastprivate(__pyx_v_quantization_error_red) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static, __pyx_t_6) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_5; __pyx_t_4++){ { __pyx_v_y = (int)(1 + 1 * __pyx_t_4); /* Initialize private variables to invalid values */ __pyx_v_new_blue = ((unsigned char)'?'); __pyx_v_new_green = ((unsigned char)'?'); __pyx_v_new_red = ((unsigned char)'?'); __pyx_v_oldb = ((unsigned char)'?'); __pyx_v_oldg = ((unsigned char)'?'); __pyx_v_oldr = ((unsigned char)'?'); __pyx_v_quantization_error_blue = ((int)0xbad0bad0); __pyx_v_quantization_error_green = ((int)0xbad0bad0); __pyx_v_quantization_error_red = ((int)0xbad0bad0); __pyx_v_x = ((int)0xbad0bad0);
7970:
+7971: for x in range(1, w):
__pyx_t_7 = __pyx_v_w; __pyx_t_8 = __pyx_t_7; for (__pyx_t_9 = 1; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_x = __pyx_t_9;
7972:
+7973: oldr = rgb_array_[x, y, 0]
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 0; __pyx_v_oldr = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )));
+7974: oldg = rgb_array_[x, y, 1]
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 1; __pyx_v_oldg = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )));
+7975: oldb = rgb_array_[x, y, 2]
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 2; __pyx_v_oldb = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )));
7976:
7977:
+7978: new_red = <unsigned int> (<int>nearbyint(c6 * oldr) * <int>c5)
__pyx_v_new_red = ((unsigned int)(((int)nearbyint((__pyx_v_c6 * __pyx_v_oldr))) * ((int)__pyx_v_c5)));
+7979: new_green = <unsigned int> (<int>nearbyint(c6 * oldg) * <int>c5)
__pyx_v_new_green = ((unsigned int)(((int)nearbyint((__pyx_v_c6 * __pyx_v_oldg))) * ((int)__pyx_v_c5)));
+7980: new_blue = <unsigned int> (<int>nearbyint(c6 * oldb) * <int>c5)
__pyx_v_new_blue = ((unsigned int)(((int)nearbyint((__pyx_v_c6 * __pyx_v_oldb))) * ((int)__pyx_v_c5)));
7981:
+7982: rgb_array_[x, y, 0] = new_red
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_v_new_red;
+7983: rgb_array_[x, y, 1] = new_green
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_v_new_green;
+7984: rgb_array_[x, y, 2] = new_blue
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) )) = __pyx_v_new_blue;
7985:
+7986: quantization_error_red = int(oldr - new_red)
__pyx_v_quantization_error_red = (__pyx_v_oldr - __pyx_v_new_red);
+7987: quantization_error_green = int(oldg - new_green)
__pyx_v_quantization_error_green = (__pyx_v_oldg - __pyx_v_new_green);
+7988: quantization_error_blue = int(oldb - new_blue)
__pyx_v_quantization_error_blue = (__pyx_v_oldb - __pyx_v_new_blue);
7989:
+7990: rgb_array_[x + 1, y, 0] = \
__pyx_t_13 = (__pyx_v_x + 1); __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C1)));
+7991: <unsigned char>(rgb_array_[x + 1, y, 0] + quantization_error_red * C1)
__pyx_t_10 = (__pyx_v_x + 1); __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 0;
+7992: rgb_array_[x + 1, y, 1] = \
__pyx_t_15 = (__pyx_v_x + 1); __pyx_t_14 = __pyx_v_y; __pyx_t_13 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C1)));
+7993: <unsigned char>(rgb_array_[x + 1, y, 1] + quantization_error_green * C1)
__pyx_t_12 = (__pyx_v_x + 1); __pyx_t_11 = __pyx_v_y; __pyx_t_10 = 1;
+7994: rgb_array_[x + 1, y, 2] = \
__pyx_t_13 = (__pyx_v_x + 1); __pyx_t_14 = __pyx_v_y; __pyx_t_15 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C1)));
+7995: <unsigned char>(rgb_array_[x + 1, y, 2] + quantization_error_blue * C1)
__pyx_t_10 = (__pyx_v_x + 1); __pyx_t_11 = __pyx_v_y; __pyx_t_12 = 2;
7996:
+7997: rgb_array_[x - 1, y + 1, 0] = \
__pyx_t_15 = (__pyx_v_x - 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C2)));
+7998: <unsigned char>(rgb_array_[x - 1, y + 1, 0] + quantization_error_red * C2)
__pyx_t_12 = (__pyx_v_x - 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 0;
+7999: rgb_array_[x - 1, y + 1, 1] = \
__pyx_t_13 = (__pyx_v_x - 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C2)));
+8000: <unsigned char>(rgb_array_[x - 1, y + 1, 1] + quantization_error_green * C2)
__pyx_t_10 = (__pyx_v_x - 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 1;
+8001: rgb_array_[x - 1, y + 1, 2] = \
__pyx_t_15 = (__pyx_v_x - 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C2)));
+8002: <unsigned char>(rgb_array_[x - 1, y + 1, 2] + quantization_error_blue * C2)
__pyx_t_12 = (__pyx_v_x - 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 2;
8003:
+8004: rgb_array_[x, y + 1, 0] = \
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C3)));
+8005: <unsigned char>(rgb_array_[x, y + 1, 0] + quantization_error_red * C3)
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 0;
+8006: rgb_array_[x, y + 1, 1] = \
__pyx_t_15 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C3)));
+8007: <unsigned char>(rgb_array_[x, y + 1, 1] + quantization_error_green * C3)
__pyx_t_12 = __pyx_v_x; __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 1;
+8008: rgb_array_[x, y + 1, 2] = \
__pyx_t_13 = __pyx_v_x; __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C3)));
+8009: <unsigned char>(rgb_array_[x, y + 1, 2] + quantization_error_blue * C3)
__pyx_t_10 = __pyx_v_x; __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 2;
8010:
+8011: rgb_array_[x + 1, y + 1, 0] = \
__pyx_t_15 = (__pyx_v_x + 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_red * __pyx_v_6shader_C4)));
+8012: <unsigned char>(rgb_array_[x + 1, y + 1, 0] + quantization_error_red * C4)
__pyx_t_12 = (__pyx_v_x + 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 0;
+8013: rgb_array_[x + 1, y + 1, 1] = \
__pyx_t_13 = (__pyx_v_x + 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_15 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_13 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_15 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_10 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_12 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_green * __pyx_v_6shader_C4)));
+8014: <unsigned char>(rgb_array_[x + 1, y + 1, 1] + quantization_error_green * C4)
__pyx_t_10 = (__pyx_v_x + 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_12 = 1;
+8015: rgb_array_[x + 1, y + 1, 2] = \
__pyx_t_15 = (__pyx_v_x + 1); __pyx_t_14 = (__pyx_v_y + 1); __pyx_t_13 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_15 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_14 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_13 * __pyx_v_rgb_array_.strides[2]) )) = ((unsigned char)((*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_12 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_11 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array_.strides[2]) ))) + (__pyx_v_quantization_error_blue * __pyx_v_6shader_C4))); } } } } } } #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 }
+8016: <unsigned char>(rgb_array_[x + 1, y + 1, 2] + quantization_error_blue * C4)
__pyx_t_12 = (__pyx_v_x + 1); __pyx_t_11 = (__pyx_v_y + 1); __pyx_t_10 = 2;
8017:
8018:
8019:
8020: @cython.boundscheck(False)
8021: @cython.wraparound(False)
8022: @cython.nonecheck(False)
8023: @cython.cdivision(True)
+8024: cdef inline void convert_27colors_c(
static CYTHON_INLINE void __pyx_f_6shader_convert_27colors_c(__Pyx_memviewslice __pyx_v_rgb_array) { Py_ssize_t __pyx_v_w; CYTHON_UNUSED Py_ssize_t __pyx_v_h; int __pyx_v_x; int __pyx_v_y; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; float __pyx_v_f; float __pyx_v_c1; CYTHON_UNUSED int __pyx_v_index; float __pyx_v_rr; float __pyx_v_gg; float __pyx_v_bb; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_27colors_c", 0); /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
8025: unsigned char [:, :, :] rgb_array):
8026:
8027: """
8028: THIS ALGORITHM CONVERT AN IMAGE USING 27 COLORS ONLY
8029:
8030: :param rgb_array: numpy.ndarray; containing the pixels RGB. Array shape (w, h, 3)
8031: :return: void
8032: """
8033: cdef Py_ssize_t w, h
+8034: w, h = rgb_array.shape[:2]
__pyx_t_1 = __pyx_v_rgb_array.shape; __pyx_t_2 = (__pyx_t_1[0]); __pyx_t_3 = (__pyx_t_1[1]); __pyx_v_w = __pyx_t_2; __pyx_v_h = __pyx_t_3;
8035:
8036: cdef:
+8037: int x=0
__pyx_v_x = 0;
+8038: int y=0
__pyx_v_y = 0;
8039: unsigned char *r
8040: unsigned char *g
8041: unsigned char *b
+8042: float f = <float> 255.0 / <float> 2
__pyx_v_f = (((float)255.0) / ((float)2));
+8043: float c1 = <float>2 / <float>255.0
__pyx_v_c1 = (((float)2) / ((float)255.0));
+8044: int index = 0
__pyx_v_index = 0;
8045: float rr, gg, bb
8046:
+8047: 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:; } }
+8048: for y in prange(h, schedule='static', num_threads=THREADS):
__pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) /* … */ __pyx_t_3 = __pyx_v_h; 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_4 = (__pyx_t_3 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_bb) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gg) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rr) lastprivate(__pyx_v_x) firstprivate(__pyx_v_y) lastprivate(__pyx_v_y) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_4; __pyx_t_2++){ { __pyx_v_y = (int)(0 + 1 * __pyx_t_2); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_bb = ((float)__PYX_NAN()); __pyx_v_g = ((unsigned char *)1); __pyx_v_gg = ((float)__PYX_NAN()); __pyx_v_r = ((unsigned char *)1); __pyx_v_rr = ((float)__PYX_NAN()); __pyx_v_x = ((int)0xbad0bad0);
+8049: for x in range(0, w):
__pyx_t_5 = __pyx_v_w; __pyx_t_6 = __pyx_t_5; for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) { __pyx_v_x = __pyx_t_7;
8050:
+8051: r = &rgb_array[x, y, 0]
__pyx_t_8 = __pyx_v_x; __pyx_t_9 = __pyx_v_y; __pyx_t_10 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
+8052: g = &rgb_array[x, y, 1]
__pyx_t_10 = __pyx_v_x; __pyx_t_9 = __pyx_v_y; __pyx_t_8 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_10 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_8 * __pyx_v_rgb_array.strides[2]) ))));
+8053: b = &rgb_array[x, y, 2]
__pyx_t_8 = __pyx_v_x; __pyx_t_9 = __pyx_v_y; __pyx_t_10 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_8 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[2]) ))));
8054:
+8055: rr = <float>round_c(c1 * <float> r[ 0 ] ) * f
__pyx_v_rr = (((float)round((__pyx_v_c1 * ((float)(__pyx_v_r[0]))))) * __pyx_v_f);
+8056: gg = <float>round_c(c1 * <float> g[ 0 ] ) * f
__pyx_v_gg = (((float)round((__pyx_v_c1 * ((float)(__pyx_v_g[0]))))) * __pyx_v_f);
+8057: bb = <float>round_c(c1 * <float> b[ 0 ] ) * f
__pyx_v_bb = (((float)round((__pyx_v_c1 * ((float)(__pyx_v_b[0]))))) * __pyx_v_f);
8058:
+8059: r[ 0 ] = <unsigned char>rr
(__pyx_v_r[0]) = ((unsigned char)__pyx_v_rr);
+8060: g[ 0 ] = <unsigned char>gg
(__pyx_v_g[0]) = ((unsigned char)__pyx_v_gg);
+8061: b[ 0 ] = <unsigned char>bb
(__pyx_v_b[0]) = ((unsigned char)__pyx_v_bb); } } } } } } #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 }
8062:
8063:
8064: @cython.binding(False)
8065: @cython.boundscheck(False)
8066: @cython.wraparound(False)
8067: @cython.nonecheck(False)
8068: @cython.cdivision(True)
+8069: cdef object spectrum_c(int width, int height, float gamma=1.0):
static PyObject *__pyx_f_6shader_spectrum_c(int __pyx_v_width, int __pyx_v_height, struct __pyx_opt_args_6shader_spectrum_c *__pyx_optional_args) { float __pyx_v_gamma = ((float)1.0); int __pyx_v_i; int __pyx_v_k; struct rgb_color_int __pyx_v_rgb_c; __Pyx_memviewslice __pyx_v_spectrum_array = { 0, 0, { 0 }, { 0 }, { 0 } }; PyObject *__pyx_v_surface = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("spectrum_c", 0); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_gamma = __pyx_optional_args->gamma; } } /* … */ /* 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_6); __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("shader.spectrum_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_spectrum_array, 1); __Pyx_XDECREF(__pyx_v_surface); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_6shader_spectrum_c { int __pyx_n; float gamma; };
8070:
8071: """
8072: CREATE A PYGAME SURFACE DISPLAYING THE LIGHT SPECTRUM 380-750 nm
8073:
8074: Color Wavelength(nm) Frequency(THz)
8075: Red 620-750 484-400
8076: Orange 590-620 508-484
8077: Yellow 570-590 526-508
8078: Green 495-570 606-526
8079: Blue 450-495 668-606
8080: Violet 380-450 789-668
8081:
8082: :param width: integer; width of the image
8083: :param height: integer; height of the image
8084: :param gamma: float; gamma value
8085: :return: Return a pygame surface 24-bit (width, height) converted for fast
8086: blit
8087:
8088: """
8089:
8090: cdef:
8091: int i, j, k
8092: rgb_color_int rgb_c
8093: unsigned char [:, :, :] spectrum_array =\
+8094: numpy.empty((370, 1, 3), numpy.uint8)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_uint8); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_tuple__26, __pyx_t_4}; __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_tuple__26, __pyx_t_4}; __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_tuple__26); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_dsdsds_unsigned_char(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_spectrum_array = __pyx_t_7; __pyx_t_7.memview = NULL; __pyx_t_7.data = NULL; /* … */ __pyx_tuple__26 = PyTuple_Pack(3, __pyx_int_370, __pyx_int_1, __pyx_int_3); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(1, 8094, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26);
8095: object surface
8096:
+8097: 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:; } }
+8098: for i in prange(380, 750, schedule='static', num_threads=THREADS):
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_9 = (0x2EE - 0x17C + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_k) lastprivate(__pyx_v_rgb_c) schedule(static) /* … */ 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_9 = (0x2EE - 0x17C + 1 - 1/abs(1)) / 1; if (__pyx_t_9 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_k) lastprivate(__pyx_v_rgb_c) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_9; __pyx_t_8++){ { __pyx_v_i = (int)(0x17C + 1 * __pyx_t_8); /* Initialize private variables to invalid values */ __pyx_v_k = ((int)0xbad0bad0);
+8099: rgb_c = wavelength_to_rgb(i, gamma)
__pyx_v_rgb_c = wavelength_to_rgb(__pyx_v_i, __pyx_v_gamma);
+8100: k = i - 380
__pyx_v_k = (__pyx_v_i - 0x17C);
+8101: spectrum_array[ k, 0, 0 ] = rgb_c.r
__pyx_t_5 = __pyx_v_rgb_c.r; __pyx_t_10 = __pyx_v_k; __pyx_t_11 = 0; __pyx_t_12 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_spectrum_array.data + __pyx_t_10 * __pyx_v_spectrum_array.strides[0]) ) + __pyx_t_11 * __pyx_v_spectrum_array.strides[1]) ) + __pyx_t_12 * __pyx_v_spectrum_array.strides[2]) )) = __pyx_t_5;
+8102: spectrum_array[ k, 0, 1 ] = rgb_c.g
__pyx_t_5 = __pyx_v_rgb_c.g; __pyx_t_12 = __pyx_v_k; __pyx_t_11 = 0; __pyx_t_10 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_spectrum_array.data + __pyx_t_12 * __pyx_v_spectrum_array.strides[0]) ) + __pyx_t_11 * __pyx_v_spectrum_array.strides[1]) ) + __pyx_t_10 * __pyx_v_spectrum_array.strides[2]) )) = __pyx_t_5;
+8103: spectrum_array[ k, 0, 2 ] = rgb_c.b
__pyx_t_5 = __pyx_v_rgb_c.b; __pyx_t_10 = __pyx_v_k; __pyx_t_11 = 0; __pyx_t_12 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_spectrum_array.data + __pyx_t_10 * __pyx_v_spectrum_array.strides[0]) ) + __pyx_t_11 * __pyx_v_spectrum_array.strides[1]) ) + __pyx_t_12 * __pyx_v_spectrum_array.strides[2]) )) = __pyx_t_5;
+8104: spectrum_array[ k, 1, 0 ] = rgb_c.r
__pyx_t_5 = __pyx_v_rgb_c.r; __pyx_t_12 = __pyx_v_k; __pyx_t_11 = 1; __pyx_t_10 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_spectrum_array.data + __pyx_t_12 * __pyx_v_spectrum_array.strides[0]) ) + __pyx_t_11 * __pyx_v_spectrum_array.strides[1]) ) + __pyx_t_10 * __pyx_v_spectrum_array.strides[2]) )) = __pyx_t_5;
+8105: spectrum_array[ k, 1, 1 ] = rgb_c.g
__pyx_t_5 = __pyx_v_rgb_c.g; __pyx_t_10 = __pyx_v_k; __pyx_t_11 = 1; __pyx_t_12 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_spectrum_array.data + __pyx_t_10 * __pyx_v_spectrum_array.strides[0]) ) + __pyx_t_11 * __pyx_v_spectrum_array.strides[1]) ) + __pyx_t_12 * __pyx_v_spectrum_array.strides[2]) )) = __pyx_t_5;
+8106: spectrum_array[ k, 1, 2 ] = rgb_c.b
__pyx_t_5 = __pyx_v_rgb_c.b; __pyx_t_12 = __pyx_v_k; __pyx_t_11 = 1; __pyx_t_10 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_spectrum_array.data + __pyx_t_12 * __pyx_v_spectrum_array.strides[0]) ) + __pyx_t_11 * __pyx_v_spectrum_array.strides[1]) ) + __pyx_t_10 * __pyx_v_spectrum_array.strides[2]) )) = __pyx_t_5; } } } } } #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 }
8107:
+8108: surface = make_surface(asarray(spectrum_array))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_make_surface); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_spectrum_array, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_13 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_6 = (__pyx_t_13) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_13, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_surface = __pyx_t_1; __pyx_t_1 = 0;
+8109: surface = scale(surface, (width, height)).convert()
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_scale); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_2); __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_surface, __pyx_t_13}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_surface, __pyx_t_13}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { __pyx_t_4 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_2) { __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; } __Pyx_INCREF(__pyx_v_surface); __Pyx_GIVEREF(__pyx_v_surface); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_5, __pyx_v_surface); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_5, __pyx_t_13); __pyx_t_13 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_convert); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_surface, __pyx_t_1); __pyx_t_1 = 0;
+8110: return surface
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_surface); __pyx_r = __pyx_v_surface; goto __pyx_L0;
8111:
8112:
8113:
8114:
8115: @cython.binding(False)
8116: @cython.boundscheck(False)
8117: @cython.wraparound(False)
8118: @cython.nonecheck(False)
8119: @cython.cdivision(True)
+8120: cdef inline void palette_change_c(
static CYTHON_INLINE void __pyx_f_6shader_palette_change_c(__Pyx_memviewslice __pyx_v_rgb_array, __Pyx_memviewslice __pyx_v_palette_) { int __pyx_v_i; int __pyx_v_j; CYTHON_UNUSED Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; struct rgb __pyx_v_rgb_; struct rgb __pyx_v_rgb_c; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; Py_ssize_t __pyx_v_p_length; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("palette_change_c", 0); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_WriteUnraisable("shader.palette_change_c", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
8121: unsigned char [:, :, :] rgb_array,
8122: float [:, :] palette_):
8123:
8124:
8125: cdef:
8126: int i, j
+8127: Py_ssize_t w = <object>rgb_array.shape[0]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_w = __pyx_t_2;
+8128: Py_ssize_t h = <object>rgb_array.shape[1]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array.shape[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8128, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8128, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_2;
8129: rgb rgb_
8130: rgb rgb_c
8131: unsigned char *r
8132: unsigned char *g
8133: unsigned char *b
+8134: Py_ssize_t p_length = <object>palette_.shape[0]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_palette_.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_p_length = __pyx_t_2;
8135:
+8136: 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:; } }
+8137: for i in prange(w, schedule='static', num_threads=THREADS, chunksize=w * h):
__pyx_t_2 = __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_4 = (__pyx_t_2 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) __pyx_t_5 = (__pyx_v_w * __pyx_v_h); /* … */ __pyx_t_2 = __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_4 = (__pyx_t_2 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_4 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) lastprivate(__pyx_v_r) lastprivate(__pyx_v_rgb_) schedule(static, __pyx_t_5) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_4; __pyx_t_3++){ { __pyx_v_i = (int)(0 + 1 * __pyx_t_3); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_j = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1);
+8138: for j in range(h):
__pyx_t_6 = __pyx_v_h; __pyx_t_7 = __pyx_t_6; for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_j = __pyx_t_8;
+8139: r = &rgb_array[i, j, 0]
__pyx_t_9 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_11 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_9 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_array.strides[2]) ))));
+8140: g = &rgb_array[i, j, 1]
__pyx_t_11 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_9 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_11 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_9 * __pyx_v_rgb_array.strides[2]) ))));
+8141: b = &rgb_array[i, j, 2]
__pyx_t_9 = __pyx_v_i; __pyx_t_10 = __pyx_v_j; __pyx_t_11 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array.data + __pyx_t_9 * __pyx_v_rgb_array.strides[0]) ) + __pyx_t_10 * __pyx_v_rgb_array.strides[1]) ) + __pyx_t_11 * __pyx_v_rgb_array.strides[2]) ))));
8142:
+8143: rgb_c.r = r[0]
__pyx_v_rgb_c.r = (__pyx_v_r[0]);
+8144: rgb_c.g = g[0]
__pyx_v_rgb_c.g = (__pyx_v_g[0]);
+8145: rgb_c.b = b[0]
__pyx_v_rgb_c.b = (__pyx_v_b[0]);
8146:
+8147: rgb_ = close_color(rgb_c, palette_, p_length)
__pyx_v_rgb_ = __pyx_f_12PygameShader_4misc_close_color(__pyx_v_rgb_c, __pyx_v_palette_, __pyx_v_p_length);
8148:
+8149: r[0] = <unsigned char>rgb_.r
(__pyx_v_r[0]) = ((unsigned char)__pyx_v_rgb_.r);
+8150: g[0] = <unsigned char>rgb_.g
(__pyx_v_g[0]) = ((unsigned char)__pyx_v_rgb_.g);
+8151: b[0] = <unsigned char>rgb_.b
(__pyx_v_b[0]) = ((unsigned char)__pyx_v_rgb_.b); } } } } } } #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 }
8152:
8153:
8154:
8155:
8156: @cython.boundscheck(False)
8157: @cython.wraparound(False)
8158: @cython.nonecheck(False)
8159: @cython.cdivision(True)
+8160: cdef float distance_ (float x1, float y1, float x2, float y2)nogil:
static float __pyx_f_6shader_distance_(float __pyx_v_x1, float __pyx_v_y1, float __pyx_v_x2, float __pyx_v_y2) { float __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; }
+8161: return <float>sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
__pyx_r = ((float)sqrt((((__pyx_v_x1 - __pyx_v_x2) * (__pyx_v_x1 - __pyx_v_x2)) + ((__pyx_v_y1 - __pyx_v_y2) * (__pyx_v_y1 - __pyx_v_y2))))); goto __pyx_L0;
8162:
8163: @cython.boundscheck(False)
8164: @cython.wraparound(False)
8165: @cython.nonecheck(False)
8166: @cython.cdivision(True)
+8167: cdef float gaussian_ (float v, float sigma2)nogil:
static float __pyx_f_6shader_gaussian_(float __pyx_v_v, float __pyx_v_sigma2) { float __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; }
+8168: return (<float>1.0 / (<float>M_PI * sigma2)) * <float>exp(-(v * v ) / sigma2)
__pyx_r = ((((float)1.0) / (((float)__pyx_v_6shader_M_PI) * __pyx_v_sigma2)) * ((float)exp(((-(__pyx_v_v * __pyx_v_v)) / __pyx_v_sigma2)))); goto __pyx_L0;
8169:
8170: @cython.boundscheck(False)
8171: @cython.wraparound(False)
8172: @cython.nonecheck(False)
8173: @cython.cdivision(True)
+8174: cdef bilateral_filter24_c(
static PyObject *__pyx_f_6shader_bilateral_filter24_c(__Pyx_memviewslice __pyx_v_rgb_array_, float __pyx_v_sigma_s_, float __pyx_v_sigma_i_) { Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_bilateral = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; int __pyx_v_k; int __pyx_v_kx; int __pyx_v_ky; float __pyx_v_gs; float __pyx_v_wr; float __pyx_v_wg; float __pyx_v_wb; float __pyx_v_ir; float __pyx_v_ig; float __pyx_v_ib; float __pyx_v_wpr; float __pyx_v_wpg; float __pyx_v_wpb; unsigned char *__pyx_v_r; unsigned char *__pyx_v_g; unsigned char *__pyx_v_b; float __pyx_v_sigma_i2; float __pyx_v_sigma_s2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("bilateral_filter24_c", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1); __Pyx_XDECREF(__pyx_t_25); __Pyx_XDECREF(__pyx_t_26); __Pyx_AddTraceback("shader.bilateral_filter24_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __PYX_XDEC_MEMVIEW(&__pyx_v_bilateral, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
8175: unsigned char [:, :, :] rgb_array_,
8176: float sigma_s_,
8177: float sigma_i_
8178: ):
8179: """
8180: A bilateral filter is a non-linear, edge-preserving, and noise-reducing
8181: smoothing filter for images. It replaces the intensity of each pixel with a
8182: weighted average of intensity values from nearby pixels. This weight can be
8183: based on a Gaussian distribution.
8184:
8185: Here, the normalization factor and the range weight are new terms added to
8186: the previous equation. sigma_s denotes the spatial extent of the kernel, i.e.
8187: the size of the neighborhood, and sigma_r denotes the minimum amplitude of an edge.
8188: It ensures that only those pixels with intensity values similar to that of the
8189: central pixel are considered for blurring, while sharp intensity changes are maintained.
8190: The smaller the value of sigma_r , the sharper the edge. As sigma_r tends to infinity,
8191: the equation tends to a Gaussian blur.
8192:
8193: :param rgb_array_: Surface, 24-32 bit format (alpha channel will be ignored)
8194:
8195: :param sigma_s_: float sigma_s : Spatial extent of the kernel, size of the
8196: considered neighborhood
8197:
8198: :param sigma_i_: float sigma_i (also call sigma_r) range kernel, minimum amplitude of an edge.
8199:
8200: :return: return a filtered Surface
8201: """
8202:
8203: cdef Py_ssize_t w, h
+8204: w = <object>rgb_array_.shape[ 0 ]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_w = __pyx_t_2;
+8205: h = <object> rgb_array_.shape[ 1 ]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_2;
8206:
8207: cdef:
+8208: unsigned char [:, :, :] bilateral = empty((h, w, 3), dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_int_3); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_uint8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __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_dsdsds_unsigned_char(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(1, 8208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_bilateral = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
8209: int x, y, xx, yy
+8210: int k = 3
__pyx_v_k = 3;
8211: int kx, ky
8212: float gs, wr, wg, wb, ir, ig, ib , wpr, wpg, wpb
8213: unsigned char *r
8214: unsigned char *g
8215: unsigned char *b
+8216: float sigma_i2 = 2 * sigma_i_ * sigma_i_
__pyx_v_sigma_i2 = ((2.0 * __pyx_v_sigma_i_) * __pyx_v_sigma_i_);
+8217: float sigma_s2 = 2 * sigma_s_ * sigma_s_
__pyx_v_sigma_s2 = ((2.0 * __pyx_v_sigma_s_) * __pyx_v_sigma_s_);
8218:
+8219: 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:; } }
8220:
+8221: for x in prange(0, w, schedule='static', num_threads=THREADS):
__pyx_t_2 = __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_8 = (__pyx_t_2 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_8 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gs) lastprivate(__pyx_v_ib) lastprivate(__pyx_v_ig) lastprivate(__pyx_v_ir) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_r) lastprivate(__pyx_v_wb) lastprivate(__pyx_v_wg) lastprivate(__pyx_v_wpb) lastprivate(__pyx_v_wpg) lastprivate(__pyx_v_wpr) lastprivate(__pyx_v_wr) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_2 = __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_8 = (__pyx_t_2 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_8 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_g) lastprivate(__pyx_v_gs) lastprivate(__pyx_v_ib) lastprivate(__pyx_v_ig) lastprivate(__pyx_v_ir) lastprivate(__pyx_v_kx) lastprivate(__pyx_v_ky) lastprivate(__pyx_v_r) lastprivate(__pyx_v_wb) lastprivate(__pyx_v_wg) lastprivate(__pyx_v_wpb) lastprivate(__pyx_v_wpg) lastprivate(__pyx_v_wpr) lastprivate(__pyx_v_wr) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_8; __pyx_t_7++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_7); /* Initialize private variables to invalid values */ __pyx_v_b = ((unsigned char *)1); __pyx_v_g = ((unsigned char *)1); __pyx_v_gs = ((float)__PYX_NAN()); __pyx_v_ib = ((float)__PYX_NAN()); __pyx_v_ig = ((float)__PYX_NAN()); __pyx_v_ir = ((float)__PYX_NAN()); __pyx_v_kx = ((int)0xbad0bad0); __pyx_v_ky = ((int)0xbad0bad0); __pyx_v_r = ((unsigned char *)1); __pyx_v_wb = ((float)__PYX_NAN()); __pyx_v_wg = ((float)__PYX_NAN()); __pyx_v_wpb = ((float)__PYX_NAN()); __pyx_v_wpg = ((float)__PYX_NAN()); __pyx_v_wpr = ((float)__PYX_NAN()); __pyx_v_wr = ((float)__PYX_NAN()); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
+8222: for y in range(0, h):
__pyx_t_9 = __pyx_v_h; __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_y = __pyx_t_11;
8223:
+8224: ir, ig, ib = 0, 0, 0
__pyx_t_12 = 0.0; __pyx_t_13 = 0.0; __pyx_t_14 = 0.0; __pyx_v_ir = __pyx_t_12; __pyx_v_ig = __pyx_t_13; __pyx_v_ib = __pyx_t_14;
+8225: wpr, wpg, wpb = 0, 0, 0
__pyx_t_14 = 0.0; __pyx_t_13 = 0.0; __pyx_t_12 = 0.0; __pyx_v_wpr = __pyx_t_14; __pyx_v_wpg = __pyx_t_13; __pyx_v_wpb = __pyx_t_12;
8226:
+8227: for ky in range(-k, k + 1):
__pyx_t_15 = (__pyx_v_k + 1); __pyx_t_16 = __pyx_t_15; for (__pyx_t_17 = (-__pyx_v_k); __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) { __pyx_v_ky = __pyx_t_17;
+8228: for kx in range(-k, k + 1):
__pyx_t_18 = (__pyx_v_k + 1); __pyx_t_19 = __pyx_t_18; for (__pyx_t_20 = (-__pyx_v_k); __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) { __pyx_v_kx = __pyx_t_20;
8229:
+8230: xx = x + kx
__pyx_v_xx = (__pyx_v_x + __pyx_v_kx);
+8231: yy = y + ky
__pyx_v_yy = (__pyx_v_y + __pyx_v_ky);
8232:
+8233: if xx < 0:
__pyx_t_21 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_21) { /* … */ goto __pyx_L16; }
+8234: xx = 0
__pyx_v_xx = 0;
+8235: elif xx > w:
__pyx_t_21 = ((__pyx_v_xx > __pyx_v_w) != 0); if (__pyx_t_21) { /* … */ } __pyx_L16:;
+8236: xx = w
__pyx_v_xx = __pyx_v_w;
8237:
+8238: if yy < 0:
__pyx_t_21 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_21) { /* … */ goto __pyx_L17; }
+8239: yy = 0
__pyx_v_yy = 0;
+8240: elif yy > h:
__pyx_t_21 = ((__pyx_v_yy > __pyx_v_h) != 0); if (__pyx_t_21) { /* … */ } __pyx_L17:;
+8241: yy = h
__pyx_v_yy = __pyx_v_h;
8242:
+8243: gs = gaussian_(distance_(xx, yy, x, y), sigma_s2)
__pyx_v_gs = __pyx_f_6shader_gaussian_(__pyx_f_6shader_distance_(__pyx_v_xx, __pyx_v_yy, __pyx_v_x, __pyx_v_y), __pyx_v_sigma_s2);
8244:
+8245: r = &rgb_array_[xx, yy, 0]
__pyx_t_22 = __pyx_v_xx; __pyx_t_23 = __pyx_v_yy; __pyx_t_24 = 0; __pyx_v_r = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_22 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[2]) ))));
+8246: g = &rgb_array_[xx, yy, 1]
__pyx_t_24 = __pyx_v_xx; __pyx_t_23 = __pyx_v_yy; __pyx_t_22 = 1; __pyx_v_g = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_24 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array_.strides[2]) ))));
+8247: b = &rgb_array_[xx, yy, 2]
__pyx_t_22 = __pyx_v_xx; __pyx_t_23 = __pyx_v_yy; __pyx_t_24 = 2; __pyx_v_b = (&(*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_22 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[2]) ))));
8248:
+8249: wr = gaussian_(r[0] - rgb_array_[x, y, 0], sigma_i2) * gs
__pyx_t_24 = __pyx_v_x; __pyx_t_23 = __pyx_v_y; __pyx_t_22 = 0; __pyx_v_wr = (__pyx_f_6shader_gaussian_(((__pyx_v_r[0]) - (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_24 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array_.strides[2]) )))), __pyx_v_sigma_i2) * __pyx_v_gs);
+8250: wg = gaussian_(g[0] - rgb_array_[x, y, 1], sigma_i2) * gs
__pyx_t_22 = __pyx_v_x; __pyx_t_23 = __pyx_v_y; __pyx_t_24 = 1; __pyx_v_wg = (__pyx_f_6shader_gaussian_(((__pyx_v_g[0]) - (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_22 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[2]) )))), __pyx_v_sigma_i2) * __pyx_v_gs);
+8251: wb = gaussian_(b[0] - rgb_array_[x, y, 2], sigma_i2) * gs
__pyx_t_24 = __pyx_v_x; __pyx_t_23 = __pyx_v_y; __pyx_t_22 = 2; __pyx_v_wb = (__pyx_f_6shader_gaussian_(((__pyx_v_b[0]) - (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_24 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_22 * __pyx_v_rgb_array_.strides[2]) )))), __pyx_v_sigma_i2) * __pyx_v_gs);
8252:
+8253: ir = ir + r[0] * wr
__pyx_v_ir = (__pyx_v_ir + ((__pyx_v_r[0]) * __pyx_v_wr));
+8254: ig = ig + g[0] * wg
__pyx_v_ig = (__pyx_v_ig + ((__pyx_v_g[0]) * __pyx_v_wg));
+8255: ib = ib + b[0] * wb
__pyx_v_ib = (__pyx_v_ib + ((__pyx_v_b[0]) * __pyx_v_wb));
8256:
+8257: wpr = wpr + wr
__pyx_v_wpr = (__pyx_v_wpr + __pyx_v_wr);
+8258: wpg = wpg + wg
__pyx_v_wpg = (__pyx_v_wpg + __pyx_v_wg);
+8259: wpb = wpb + wb
__pyx_v_wpb = (__pyx_v_wpb + __pyx_v_wb); } }
8260:
+8261: ir = ir / wpr
__pyx_v_ir = (__pyx_v_ir / __pyx_v_wpr);
+8262: ig = ig / wpg
__pyx_v_ig = (__pyx_v_ig / __pyx_v_wpg);
+8263: ib = ib / wpb
__pyx_v_ib = (__pyx_v_ib / __pyx_v_wpb);
8264:
+8265: bilateral[y, x, 0] = <int>ir
__pyx_t_22 = __pyx_v_y; __pyx_t_23 = __pyx_v_x; __pyx_t_24 = 0; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_bilateral.data + __pyx_t_22 * __pyx_v_bilateral.strides[0]) ) + __pyx_t_23 * __pyx_v_bilateral.strides[1]) ) + __pyx_t_24 * __pyx_v_bilateral.strides[2]) )) = ((int)__pyx_v_ir);
+8266: bilateral[y, x, 1] = <int>ig
__pyx_t_24 = __pyx_v_y; __pyx_t_23 = __pyx_v_x; __pyx_t_22 = 1; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_bilateral.data + __pyx_t_24 * __pyx_v_bilateral.strides[0]) ) + __pyx_t_23 * __pyx_v_bilateral.strides[1]) ) + __pyx_t_22 * __pyx_v_bilateral.strides[2]) )) = ((int)__pyx_v_ig);
+8267: bilateral[y, x, 2] = <int>ib
__pyx_t_22 = __pyx_v_y; __pyx_t_23 = __pyx_v_x; __pyx_t_24 = 2; *((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_bilateral.data + __pyx_t_22 * __pyx_v_bilateral.strides[0]) ) + __pyx_t_23 * __pyx_v_bilateral.strides[1]) ) + __pyx_t_24 * __pyx_v_bilateral.strides[2]) )) = ((int)__pyx_v_ib); } } } } } } #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 }
8268:
8269:
+8270: return frombuffer(bilateral, (w, h), 'RGB')
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_bilateral, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_25 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_25)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_25); __pyx_t_26 = PyTuple_New(2); if (unlikely(!__pyx_t_26)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_26); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_26, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_26, 1, __pyx_t_25); __pyx_t_1 = 0; __pyx_t_25 = 0; __pyx_t_25 = NULL; __pyx_t_11 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_25)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_25); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_11 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_25, __pyx_t_4, __pyx_t_26, __pyx_n_s_RGB}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[4] = {__pyx_t_25, __pyx_t_4, __pyx_t_26, __pyx_n_s_RGB}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_11, 3+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0; } else #endif { __pyx_t_1 = PyTuple_New(3+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_25) { __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_25); __pyx_t_25 = NULL; } __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_11, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_26); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_11, __pyx_t_26); __Pyx_INCREF(__pyx_n_s_RGB); __Pyx_GIVEREF(__pyx_n_s_RGB); PyTuple_SET_ITEM(__pyx_t_1, 2+__pyx_t_11, __pyx_n_s_RGB); __pyx_t_4 = 0; __pyx_t_26 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
8271:
8272:
8273:
8274:
8275: EMBOSS_KERNEL = \
+8276: numpy.array((
__Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_n_s_numpy); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 8276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __pyx_t_31 = __Pyx_PyObject_GetAttrStr(__pyx_t_32, __pyx_n_s_array_2); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 8276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0; /* … */ __pyx_t_29 = __Pyx_PyObject_CallOneArg(__pyx_t_31, __pyx_t_28); if (unlikely(!__pyx_t_29)) __PYX_ERR(1, 8276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0; __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
+8277: [-1, -1, -1, -1, 0],
__pyx_t_32 = PyList_New(5); if (unlikely(!__pyx_t_32)) __PYX_ERR(1, 8277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_32); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_32, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_32, 1, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_32, 2, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_32, 3, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_32, 4, __pyx_int_0); /* … */ __pyx_t_28 = PyTuple_New(5); if (unlikely(!__pyx_t_28)) __PYX_ERR(1, 8277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_28); __Pyx_GIVEREF(__pyx_t_32); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_32); __Pyx_GIVEREF(__pyx_t_30); PyTuple_SET_ITEM(__pyx_t_28, 1, __pyx_t_30); __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_28, 2, __pyx_t_33); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_28, 3, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_29); PyTuple_SET_ITEM(__pyx_t_28, 4, __pyx_t_29); __pyx_t_32 = 0; __pyx_t_30 = 0; __pyx_t_33 = 0; __pyx_t_2 = 0; __pyx_t_29 = 0;
+8278: [-1, -1, -1, 0, 1],
__pyx_t_30 = PyList_New(5); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 8278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_30, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_30, 1, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_30, 2, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_30, 3, __pyx_int_0); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_30, 4, __pyx_int_1);
+8279: [-1, -1, 0, 1, 1],
__pyx_t_33 = PyList_New(5); if (unlikely(!__pyx_t_33)) __PYX_ERR(1, 8279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_33); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_33, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_33, 1, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_33, 2, __pyx_int_0); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_33, 3, __pyx_int_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_33, 4, __pyx_int_1);
+8280: [-1, 0, 1, 1, 1],
__pyx_t_2 = PyList_New(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_neg_1); __Pyx_GIVEREF(__pyx_int_neg_1); PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_neg_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_0); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_2, 2, __pyx_int_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_2, 3, __pyx_int_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_2, 4, __pyx_int_1);
+8281: [ 0, 1, 1, 1, 1])).astype(dtype=numpy.float32, order='C')
__pyx_t_29 = PyList_New(5); if (unlikely(!__pyx_t_29)) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); PyList_SET_ITEM(__pyx_t_29, 0, __pyx_int_0); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_29, 1, __pyx_int_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_29, 2, __pyx_int_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_29, 3, __pyx_int_1); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); PyList_SET_ITEM(__pyx_t_29, 4, __pyx_int_1); /* … */ __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_n_s_astype); if (unlikely(!__pyx_t_28)) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_28); __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; __pyx_t_29 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_29)) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __Pyx_GetModuleGlobalName(__pyx_t_31, __pyx_n_s_numpy); if (unlikely(!__pyx_t_31)) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_31); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_31, __pyx_n_s_float32); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0; if (PyDict_SetItem(__pyx_t_29, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_29, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 8281, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_28, __pyx_empty_tuple, __pyx_t_29); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_EMBOSS_KERNEL, __pyx_t_2) < 0) __PYX_ERR(1, 8275, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8282:
8283: @cython.boundscheck(False)
8284: @cython.wraparound(False)
8285: @cython.nonecheck(False)
8286: @cython.cdivision(True)
+8287: cdef object emboss5x5_c(unsigned char [:, :, :] rgb_array_):
static PyObject *__pyx_f_6shader_emboss5x5_c(__Pyx_memviewslice __pyx_v_rgb_array_) { PyObject *__pyx_v_k_weight = NULL; Py_ssize_t __pyx_v_k_length; Py_ssize_t __pyx_v_half_kernel; Py_ssize_t __pyx_v_w; Py_ssize_t __pyx_v_h; __Pyx_memviewslice __pyx_v_kernel = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED float __pyx_v_kernel_weight; short __pyx_v_kernel_half; __Pyx_memviewslice __pyx_v_emboss = { 0, 0, { 0 }, { 0 }, { 0 } }; CYTHON_UNUSED int __pyx_v_kernel_length; int __pyx_v_x; int __pyx_v_y; int __pyx_v_xx; int __pyx_v_yy; unsigned short __pyx_v_red; unsigned short __pyx_v_green; unsigned short __pyx_v_blue; short __pyx_v_kernel_offset_y; short __pyx_v_kernel_offset_x; float __pyx_v_r; float __pyx_v_g; float __pyx_v_b; float __pyx_v_k; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("emboss5x5_c", 0); /* … */ /* 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_XDEC_MEMVIEW(&__pyx_t_6, 1); __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1); __Pyx_XDECREF(__pyx_t_29); __Pyx_XDECREF(__pyx_t_30); __Pyx_AddTraceback("shader.emboss5x5_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_k_weight); __PYX_XDEC_MEMVIEW(&__pyx_v_kernel, 1); __PYX_XDEC_MEMVIEW(&__pyx_v_emboss, 1); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
8288:
+8289: k_weight = numpy.sum(EMBOSS_KERNEL)
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_numpy); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_EMBOSS_KERNEL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); } } __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_k_weight = __pyx_t_1; __pyx_t_1 = 0;
+8290: k_length = len(EMBOSS_KERNEL)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_EMBOSS_KERNEL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 8290, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_k_length = __pyx_t_5;
+8291: half_kernel = len(EMBOSS_KERNEL) >> 1
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_EMBOSS_KERNEL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 8291, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_half_kernel = (__pyx_t_5 >> 1);
8292:
8293: # texture sizes
8294: cdef Py_ssize_t w, h
+8295: w = <object>rgb_array_.shape[0]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[0])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8295, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_w = __pyx_t_5;
+8296: h = <object>rgb_array_.shape[1]
__pyx_t_1 = PyInt_FromSsize_t((__pyx_v_rgb_array_.shape[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 8296, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_h = __pyx_t_5;
8297:
8298: cdef:
+8299: float [:, :] kernel = EMBOSS_KERNEL
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_EMBOSS_KERNEL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_dsds_float(__pyx_t_1, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(1, 8299, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_kernel = __pyx_t_6; __pyx_t_6.memview = NULL; __pyx_t_6.data = NULL;
+8300: float kernel_weight = k_weight
__pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_v_k_weight); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) __PYX_ERR(1, 8300, __pyx_L1_error) __pyx_v_kernel_weight = __pyx_t_7;
+8301: short kernel_half = half_kernel
__pyx_v_kernel_half = __pyx_v_half_kernel;
+8302: unsigned char [:, :, ::1] emboss = empty((h, w, 3), order='C', dtype=uint8)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); __Pyx_INCREF(__pyx_int_3); __Pyx_GIVEREF(__pyx_int_3); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_3); __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_s_C) < 0) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_uint8); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_unsigned_char(__pyx_t_3, PyBUF_WRITABLE); if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(1, 8302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_emboss = __pyx_t_8; __pyx_t_8.memview = NULL; __pyx_t_8.data = NULL;
+8303: int kernel_length = k_length
__pyx_v_kernel_length = __pyx_v_k_length;
8304: int x, y, xx, yy
8305: unsigned short red, green, blue,
8306: short kernel_offset_y, kernel_offset_x
8307: float r, g, b, k
8308:
+8309: 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:; } }
8310:
+8311: for x in prange(0, w, schedule='static', num_threads=THREADS):
__pyx_t_5 = __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_10 = (__pyx_t_5 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) /* … */ __pyx_t_5 = __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_10 = (__pyx_t_5 - 0 + 1 - 1/abs(1)) / 1; if (__pyx_t_10 > 0) { #ifdef _OPENMP #pragma omp parallel #endif /* _OPENMP */ { #ifdef _OPENMP #pragma omp for lastprivate(__pyx_v_b) lastprivate(__pyx_v_blue) lastprivate(__pyx_v_g) lastprivate(__pyx_v_green) lastprivate(__pyx_v_k) lastprivate(__pyx_v_kernel_offset_x) lastprivate(__pyx_v_kernel_offset_y) lastprivate(__pyx_v_r) lastprivate(__pyx_v_red) firstprivate(__pyx_v_x) lastprivate(__pyx_v_x) lastprivate(__pyx_v_xx) lastprivate(__pyx_v_y) lastprivate(__pyx_v_yy) schedule(static) num_threads(__pyx_v_6shader_THREADS) #endif /* _OPENMP */ for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_10; __pyx_t_9++){ { __pyx_v_x = (int)(0 + 1 * __pyx_t_9); /* Initialize private variables to invalid values */ __pyx_v_b = ((float)__PYX_NAN()); __pyx_v_blue = ((unsigned short)0xbad0bad0); __pyx_v_g = ((float)__PYX_NAN()); __pyx_v_green = ((unsigned short)0xbad0bad0); __pyx_v_k = ((float)__PYX_NAN()); __pyx_v_kernel_offset_x = ((short)0xbad0bad0); __pyx_v_kernel_offset_y = ((short)0xbad0bad0); __pyx_v_r = ((float)__PYX_NAN()); __pyx_v_red = ((unsigned short)0xbad0bad0); __pyx_v_xx = ((int)0xbad0bad0); __pyx_v_y = ((int)0xbad0bad0); __pyx_v_yy = ((int)0xbad0bad0);
8312:
+8313: for y in range(0, h):
__pyx_t_11 = __pyx_v_h; __pyx_t_12 = __pyx_t_11; for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { __pyx_v_y = __pyx_t_13;
8314:
+8315: r, g, b = 0, 0, 0
__pyx_t_7 = 0.0; __pyx_t_14 = 0.0; __pyx_t_15 = 0.0; __pyx_v_r = __pyx_t_7; __pyx_v_g = __pyx_t_14; __pyx_v_b = __pyx_t_15;
8316:
+8317: for kernel_offset_y in range(-kernel_half, kernel_half + 1):
__pyx_t_16 = (__pyx_v_kernel_half + 1); __pyx_t_17 = __pyx_t_16; for (__pyx_t_18 = (-__pyx_v_kernel_half); __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) { __pyx_v_kernel_offset_y = __pyx_t_18;
8318:
+8319: for kernel_offset_x in range(-kernel_half, kernel_half + 1):
__pyx_t_19 = (__pyx_v_kernel_half + 1); __pyx_t_20 = __pyx_t_19; for (__pyx_t_21 = (-__pyx_v_kernel_half); __pyx_t_21 < __pyx_t_20; __pyx_t_21+=1) { __pyx_v_kernel_offset_x = __pyx_t_21;
8320:
+8321: xx = x + kernel_offset_x
__pyx_v_xx = (__pyx_v_x + __pyx_v_kernel_offset_x);
+8322: yy = y + kernel_offset_y
__pyx_v_yy = (__pyx_v_y + __pyx_v_kernel_offset_y);
8323:
+8324: if xx < 0:
__pyx_t_22 = ((__pyx_v_xx < 0) != 0); if (__pyx_t_22) { /* … */ goto __pyx_L16; }
+8325: xx = 0
__pyx_v_xx = 0;
+8326: elif xx > w:
__pyx_t_22 = ((__pyx_v_xx > __pyx_v_w) != 0); if (__pyx_t_22) { /* … */ } __pyx_L16:;
+8327: xx = w
__pyx_v_xx = __pyx_v_w;
8328:
+8329: if yy < 0:
__pyx_t_22 = ((__pyx_v_yy < 0) != 0); if (__pyx_t_22) { /* … */ goto __pyx_L17; }
+8330: yy = 0
__pyx_v_yy = 0;
+8331: elif yy > h:
__pyx_t_22 = ((__pyx_v_yy > __pyx_v_h) != 0); if (__pyx_t_22) { /* … */ } __pyx_L17:;
+8332: yy = h
__pyx_v_yy = __pyx_v_h;
8333:
8334:
8335: red, green, blue = \
+8336: rgb_array_[xx, yy, 0], \
__pyx_t_23 = __pyx_v_xx; __pyx_t_24 = __pyx_v_yy; __pyx_t_25 = 0; __pyx_t_26 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_23 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) )));
+8337: rgb_array_[xx, yy, 1],\
__pyx_t_25 = __pyx_v_xx; __pyx_t_24 = __pyx_v_yy; __pyx_t_23 = 1; __pyx_t_27 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_25 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_23 * __pyx_v_rgb_array_.strides[2]) )));
+8338: rgb_array_[xx, yy, 2]
__pyx_t_23 = __pyx_v_xx; __pyx_t_24 = __pyx_v_yy; __pyx_t_25 = 2; __pyx_t_28 = (*((unsigned char *) ( /* dim=2 */ (( /* dim=1 */ (( /* dim=0 */ (__pyx_v_rgb_array_.data + __pyx_t_23 * __pyx_v_rgb_array_.strides[0]) ) + __pyx_t_24 * __pyx_v_rgb_array_.strides[1]) ) + __pyx_t_25 * __pyx_v_rgb_array_.strides[2]) ))); __pyx_v_red = __pyx_t_26; __pyx_v_green = __pyx_t_27; __pyx_v_blue = __pyx_t_28;
8339:
+8340: k = kernel[kernel_offset_y + kernel_half, kernel_offset_x + kernel_half]
__pyx_t_25 = (__pyx_v_kernel_offset_y + __pyx_v_kernel_half); __pyx_t_24 = (__pyx_v_kernel_offset_x + __pyx_v_kernel_half); __pyx_v_k = (*((float *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_kernel.data + __pyx_t_25 * __pyx_v_kernel.strides[0]) ) + __pyx_t_24 * __pyx_v_kernel.strides[1]) )));
+8341: r = r + red * k
__pyx_v_r = (__pyx_v_r + (__pyx_v_red * __pyx_v_k));
+8342: g = g + green * k
__pyx_v_g = (__pyx_v_g + (__pyx_v_green * __pyx_v_k));
+8343: b = b + blue * k
__pyx_v_b = (__pyx_v_b + (__pyx_v_blue * __pyx_v_k)); } }
8344:
+8345: if r < 0:
__pyx_t_22 = ((__pyx_v_r < 0.0) != 0); if (__pyx_t_22) { /* … */ }
+8346: r = 0
__pyx_v_r = 0.0;
+8347: if g < 0:
__pyx_t_22 = ((__pyx_v_g < 0.0) != 0); if (__pyx_t_22) { /* … */ }
+8348: g = 0
__pyx_v_g = 0.0;
+8349: if b < 0:
__pyx_t_22 = ((__pyx_v_b < 0.0) != 0); if (__pyx_t_22) { /* … */ }
+8350: b = 0
__pyx_v_b = 0.0;
+8351: if r > 255:
__pyx_t_22 = ((__pyx_v_r > 255.0) != 0); if (__pyx_t_22) { /* … */ }
+8352: r= 255
__pyx_v_r = 255.0;
+8353: if g > 255:
__pyx_t_22 = ((__pyx_v_g > 255.0) != 0); if (__pyx_t_22) { /* … */ }
+8354: g = 255
__pyx_v_g = 255.0;
+8355: if b > 255:
__pyx_t_22 = ((__pyx_v_b > 255.0) != 0); if (__pyx_t_22) { /* … */ }
+8356: b = 255
__pyx_v_b = 255.0;
8357:
+8358: emboss[y, x, 0], emboss[y, x, 1], \
__pyx_t_24 = __pyx_v_y; __pyx_t_25 = __pyx_v_x; __pyx_t_23 = 0; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_emboss.data + __pyx_t_24 * __pyx_v_emboss.strides[0]) ) + __pyx_t_25 * __pyx_v_emboss.strides[1]) )) + __pyx_t_23)) )) = __pyx_t_28; __pyx_t_23 = __pyx_v_y; __pyx_t_25 = __pyx_v_x; __pyx_t_24 = 1; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_emboss.data + __pyx_t_23 * __pyx_v_emboss.strides[0]) ) + __pyx_t_25 * __pyx_v_emboss.strides[1]) )) + __pyx_t_24)) )) = __pyx_t_27;
+8359: emboss[y, x, 2] = <unsigned char>r, <unsigned char>g, <unsigned char>b
__pyx_t_28 = ((unsigned char)__pyx_v_r); __pyx_t_27 = ((unsigned char)__pyx_v_g); __pyx_t_26 = ((unsigned char)__pyx_v_b); /* … */ __pyx_t_24 = __pyx_v_y; __pyx_t_25 = __pyx_v_x; __pyx_t_23 = 2; *((unsigned char *) ( /* dim=2 */ ((char *) (((unsigned char *) ( /* dim=1 */ (( /* dim=0 */ (__pyx_v_emboss.data + __pyx_t_24 * __pyx_v_emboss.strides[0]) ) + __pyx_t_25 * __pyx_v_emboss.strides[1]) )) + __pyx_t_23)) )) = __pyx_t_26; } } } } } } #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 }
8360:
+8361: return frombuffer(asarray(emboss), (w, h), 'RGB')
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_frombuffer); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_29 = __pyx_memoryview_fromslice(__pyx_v_emboss, 3, (PyObject *(*)(char *)) __pyx_memview_get_unsigned_char, (int (*)(char *, PyObject *)) __pyx_memview_set_unsigned_char, 0);; if (unlikely(!__pyx_t_29)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __pyx_t_30 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_30 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_30)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_30); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); } } __pyx_t_2 = (__pyx_t_30) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_30, __pyx_t_29) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_29); __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0; __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_w); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_29 = PyInt_FromSsize_t(__pyx_v_h); if (unlikely(!__pyx_t_29)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_29); __pyx_t_30 = PyTuple_New(2); if (unlikely(!__pyx_t_30)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_30); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_30, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_29); PyTuple_SET_ITEM(__pyx_t_30, 1, __pyx_t_29); __pyx_t_1 = 0; __pyx_t_29 = 0; __pyx_t_29 = NULL; __pyx_t_13 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_29 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_29)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_29); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_13 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_29, __pyx_t_2, __pyx_t_30, __pyx_n_s_RGB}; __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { PyObject *__pyx_temp[4] = {__pyx_t_29, __pyx_t_2, __pyx_t_30, __pyx_n_s_RGB}; __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0; __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0; } else #endif { __pyx_t_1 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__pyx_t_29) { __Pyx_GIVEREF(__pyx_t_29); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_29); __pyx_t_29 = NULL; } __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_13, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_30); PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_13, __pyx_t_30); __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_2 = 0; __pyx_t_30 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
8362:
8363:
8364:
8365: