Ticket #27331: patch-MyPaint.diff

File patch-MyPaint.diff, 2.5 KB (added by ak.ml@…, 14 years ago)

The patch i'm applying (just added a final newline)

  • lib/colorchanger.hpp

    a b  
    77 * (at your option) any later version.
    88 */
    99
     10const int size = 256;
     11
    1012class ColorChanger {
    1113public:
    12   static const int size = 256;
    13 
    1414  float brush_h, brush_s, brush_v;
    1515  void set_brush_color(float h, float s, float v)
    1616  {
  • lib/colorring.hpp

    a b  
    1010#include <cmath> // atan2, sqrt or hypot
    1111#include "helpers2.hpp"
    1212
     13const int colorring_size = 256; // diameter of Swiss Cheese Wheel Color Selector(TM)
     14const int center = (colorring_size/2); // radii/center coordinate of SCWCS
     15
     16// Frequently used constants
     17const float RAD_TO_ONE = 0.5f/M_PI;
     18const float TWO_PI = 2.0f*M_PI;
     19// Calculate these as precise as the hosting system can once and for all
     20const float ONE_OVER_THREE = 1.0f/3.0f;
     21const float TWO_OVER_THREE = 2.0f/3.0f;
     22 
    1323class SCWSColorSelector {
    1424public:
    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 SCWCS
    1725
    1826  /*
    1927    --------- Swiss Cheese Wheel Color Selector(TM) ---------
     
    2533   
    2634  */
    2735 
    28   // Frequently used constants
    29   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 all
    32   static const float ONE_OVER_THREE = 1.0f/3.0f;
    33   static const float TWO_OVER_THREE = 2.0f/3.0f;
    34  
    3536  float brush_h, brush_s, brush_v;
    3637  void set_brush_color(float h, float s, float v)
    3738  {
     
    127128  {
    128129    assert(PyArray_ISCARRAY(arr));
    129130    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);
    132133    assert(PyArray_DIM(arr, 2) == 4);  // memory width of pixel data ( 3 = RGB, 4 = RGBA )
    133134    guchar* pixels = (guchar*)((PyArrayObject*)arr)->data;
    134135 
     
    138139 
    139140    float ofs_h = ((brush_h+ONE_OVER_THREE)>1.0f)?(brush_h-TWO_OVER_THREE):(brush_h+ONE_OVER_THREE); // offset hue
    140141
    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++) {
    143144        get_hsva_at(&h, &s, &v, &a, x, y, false, false, ofs_h);
    144145        hsv_to_rgb_range_one(&h,&s,&v); // convert from HSV [0,1] to RGB [0,255]
    145146        pixels[0] = h; pixels[1] = s; pixels[2] = v; pixels[3] = a;