OSDN Git Service

[elliptical dabs] change angle definition from 0-360 to 0.0-1.0
authorMartin Renold <martinxyz@gmx.ch>
Tue, 2 Jun 2009 09:00:49 +0000 (09:00 +0000)
committerMartin Renold <martinxyz@gmx.ch>
Tue, 2 Jun 2009 09:00:49 +0000 (09:00 +0000)
and use "computer graphics" definition of the angle (positive is clockwise)

svn://svn.gna.org/svn/mypaint/trunk@367

brushes/order.conf
brushlib/brush.hpp
brushlib/brushsettings.py
lib/tiledsurface.hpp

index 06ba50d..684a01c 100644 (file)
@@ -1,5 +1,6 @@
 # this file saves brushorder
 # the first one (upper left) will be selected at startup
+s001
 subtle_pencil
 ink
 aspec_fun_5
index bbf4ff1..497846b 100644 (file)
@@ -287,11 +287,11 @@ private:
 
     // aspect ratio (needs to be caluclated here because it can affect the dab spacing)
 
-    float aspect_ratio = settings_value[BRUSH_ASPECT_RATIO]; 
+    float ratio = settings_value[BRUSH_ELLIPTICAL_DAB_RATIO];
     //float angle = atan2(states[STATE_NORM_DY_SLOW], -states[STATE_NORM_DX_SLOW]) / M_PI * 180;
-    float angle = settings_value[BRUSH_ASPECT_RATIO_ANGLE];
-    states[STATE_ACTUAL_ASPECT_RATIO] = aspect_ratio;
-    states[STATE_ACTUAL_ANGLE] = angle;
+    float angle = settings_value[BRUSH_ELLIPTICAL_DAB_ANGLE];
+    states[STATE_ACTUAL_ELLIPTICAL_DAB_RATIO] = ratio;
+    states[STATE_ACTUAL_ELLIPTICAL_DAB_ANGLE] = angle;
   }
 
   // Called only from stroke_to(). Calculate everything needed to
@@ -444,7 +444,7 @@ private:
     // the functions below will CLAMP most inputs
     hsv_to_rgb_float (&color_h, &color_s, &color_v);
     return surface->draw_dab (x, y, radius, color_h, color_s, color_v, opaque, hardness, eraser_target_alpha,
-                              states[STATE_ACTUAL_ASPECT_RATIO], states[STATE_ACTUAL_ANGLE]);
+                              states[STATE_ACTUAL_ELLIPTICAL_DAB_RATIO], states[STATE_ACTUAL_ELLIPTICAL_DAB_ANGLE]);
   }
 
   // How many dabs will be drawn between the current and the next (x, y, pressure, +dt) position?
@@ -471,12 +471,13 @@ private:
     //dp = pressure - pressure; // Not useful?
     // TODO: control rate with pressure (dabs per pressure) (dpressure is useless)
 
-    if (states[STATE_ACTUAL_ASPECT_RATIO] > 1.0) {
-      float angle_rad=states[STATE_ACTUAL_ANGLE]*M_PI/180.0;
+    if (states[STATE_ACTUAL_ELLIPTICAL_DAB_RATIO] > 1.0) {
+      // code duplication, see tiledsurface::draw_dab()
+      float angle_rad=states[STATE_ACTUAL_ELLIPTICAL_DAB_ANGLE]*2*M_PI;
       float cs=cos(angle_rad);
       float sn=sin(angle_rad);
-      float yyr=(yy*cs+xx*sn)*states[STATE_ACTUAL_ASPECT_RATIO];
-      float xxr=-yy*sn+xx*cs;
+      float yyr=(yy*cs-xx*sn)*states[STATE_ACTUAL_ELLIPTICAL_DAB_RATIO];
+      float xxr=yy*sn+xx*cs;
       dist = sqrt(yyr*yyr + xxr*xxr);
     } else {
       dist = hypotf(xx, yy);
index 6a119e5..0bc15e7 100644 (file)
@@ -73,8 +73,8 @@ settings_list = [
     #['dab2_opacity_fac', 'second dab opaque', False, 0.0, 0.0, 2.0, "0.0 disable the second dab\n1.0 as opaque as the first dab\n2.0 twice as opaque as the first dab"],
     #['dab2_position_noise', 'second position noise',
 
-    ['aspect_ratio', 'aspect ratio', False, 1.0, 1.0, 10.0, "[EXPERIMENTAL] aspect ratio, must be >= 1.0"],
-    ['aspect_ratio_angle', 'aspect ratio angle', False, 0.0, 45.0, 360.0, "[EXPERIMENTAL] dab angle in degrees"],
+    ['elliptical_dab_ratio', 'elliptical dab: ratio', False, 1.0, 1.0, 10.0, "aspect ratio of the dabs; must be >= 1.0, where 1.0 means a perfectly round dab. TODO: linearize? start at 0.0 maybe, or log?"],
+    ['elliptical_dab_angle', 'elliptical dab: angle', False, 0.0, 0.0, 0.5, "this defines the angle by which eliptical dabs are tilted\n 0.0 horizontal dabs\n 0.25 vertical dabs\n 0.5 horizontal again"],
     ]
 
 settings_hidden = 'color_h color_s color_v'.split()
@@ -109,7 +109,7 @@ stroke, stroke_started # stroke_started is used as boolean
 custom_input
 rng_seed
 
-actual_aspect_ratio, actual_angle # used by count_dabs_to
+actual_elliptical_dab_ratio, actual_elliptical_dab_angle # used by count_dabs_to
 '''
 
 class BrushInput:
index a7d84c9..2aa0dc5 100644 (file)
@@ -160,7 +160,7 @@ public:
         if (x1 > TILE_SIZE-1) x1 = TILE_SIZE-1;
         if (y1 > TILE_SIZE-1) y1 = TILE_SIZE-1;
 
-               float angle_rad=angle*M_PI/180.0;
+               float angle_rad=angle*2*M_PI;
                float cs=cos(angle_rad);
                float sn=sin(angle_rad);
 
@@ -168,8 +168,9 @@ public:
           yy = (yp + 0.5 - yc);
           for (xp = x0; xp <= x1; xp++) {
             xx = (xp + 0.5 - xc);
-               float yyr=(yy*cs+xx*sn)*aspect_ratio;
-                       float xxr=-yy*sn+xx*cs;
+            // code duplication, see brush::count_dabs_to()
+               float yyr=(yy*cs-xx*sn)*aspect_ratio;
+                       float xxr=yy*sn+xx*cs;
             rr = (yyr*yyr + xxr*xxr) * one_over_radius2;
             // rr is in range 0.0..1.0*sqrt(2)