Ticket #27331: patch-MyPaint.diff
File patch-MyPaint.diff, 2.5 KB (added by ak.ml@…, 14 years ago) |
---|
-
lib/colorchanger.hpp
a b 7 7 * (at your option) any later version. 8 8 */ 9 9 10 const int size = 256; 11 10 12 class ColorChanger { 11 13 public: 12 static const int size = 256;13 14 14 float brush_h, brush_s, brush_v; 15 15 void set_brush_color(float h, float s, float v) 16 16 { -
lib/colorring.hpp
a b 10 10 #include <cmath> // atan2, sqrt or hypot 11 11 #include "helpers2.hpp" 12 12 13 const int colorring_size = 256; // diameter of Swiss Cheese Wheel Color Selector(TM) 14 const int center = (colorring_size/2); // radii/center coordinate of SCWCS 15 16 // Frequently used constants 17 const float RAD_TO_ONE = 0.5f/M_PI; 18 const float TWO_PI = 2.0f*M_PI; 19 // Calculate these as precise as the hosting system can once and for all 20 const float ONE_OVER_THREE = 1.0f/3.0f; 21 const float TWO_OVER_THREE = 2.0f/3.0f; 22 13 23 class SCWSColorSelector { 14 24 public: 15 static const int size = 256; // diameter of Swiss Cheese Wheel Color Selector(TM)16 static const int center = (size/2); // radii/center coordinate of SCWCS17 25 18 26 /* 19 27 --------- Swiss Cheese Wheel Color Selector(TM) --------- … … 25 33 26 34 */ 27 35 28 // Frequently used constants29 static const float RAD_TO_ONE = 0.5f/M_PI;30 static const float TWO_PI = 2.0f*M_PI;31 // Calculate these as precise as the hosting system can once and for all32 static const float ONE_OVER_THREE = 1.0f/3.0f;33 static const float TWO_OVER_THREE = 2.0f/3.0f;34 35 36 float brush_h, brush_s, brush_v; 36 37 void set_brush_color(float h, float s, float v) 37 38 { … … 127 128 { 128 129 assert(PyArray_ISCARRAY(arr)); 129 130 assert(PyArray_NDIM(arr) == 3); 130 assert(PyArray_DIM(arr, 0) == size);131 assert(PyArray_DIM(arr, 1) == size);131 assert(PyArray_DIM(arr, 0) == colorring_size); 132 assert(PyArray_DIM(arr, 1) == colorring_size); 132 133 assert(PyArray_DIM(arr, 2) == 4); // memory width of pixel data ( 3 = RGB, 4 = RGBA ) 133 134 guchar* pixels = (guchar*)((PyArrayObject*)arr)->data; 134 135 … … 138 139 139 140 float ofs_h = ((brush_h+ONE_OVER_THREE)>1.0f)?(brush_h-TWO_OVER_THREE):(brush_h+ONE_OVER_THREE); // offset hue 140 141 141 for(float y=0; y< size; y++) {142 for(float x=0; x< size; x++) {142 for(float y=0; y<colorring_size; y++) { 143 for(float x=0; x<colorring_size; x++) { 143 144 get_hsva_at(&h, &s, &v, &a, x, y, false, false, ofs_h); 144 145 hsv_to_rgb_range_one(&h,&s,&v); // convert from HSV [0,1] to RGB [0,255] 145 146 pixels[0] = h; pixels[1] = s; pixels[2] = v; pixels[3] = a;