Martin Nordholts wrote:
>* Tim Jedlicka wrote:**
*>>* I stumbled upon this link describing the use of the Diagonal (45 degree
*>>* diagonal from each corner of an image) as the optimum crop guide ("better"
*>>* than rule-of-thirds or golden rule).

> Oops, it of course depends on portrait or landscape which line you hit
> first. I think you will have to throw in an if there.

I figured out a way to avoid the "if" statement. However, I don't know which
method would be more efficient. i.e. should I try to avoid the "if"? These
diagonal crop guides are very dynamic as you change your crop rectangle so I
don't want to bog down the rendering. Just need some guidance on which route
to take. I'll then have some follow up questions since I am not much of a
coder (I'll do this off list unless directed otherwise).

gimpregionselecttool.c has this bit of code when selecting a region:
  /* don't let the events come in too fast, ignore below a delay of 100 ms
  if (time - last_time < 100)

  last_time = time;

  diff_x = coords->x - region_sel->x;
  diff_y = coords->y - region_sel->y;

  diff = ((ABS (diff_x) > ABS (diff_y)) ? diff_x : diff_y) / 2.0;

So there "if" doesn't look like it is too costly.

The way I came up with to avoid the "if" is (pseudo code):

X = x2-x1
Y = y2-y1
Z = [(X + Y) - ABS (X - Y)] / 2
So the upper left diagonal would go from x1,y1 to (x1 + Z), (y1 + Z)

Any advice on which way to implement?
Tim Jedlicka, Network Entomologist
Gimp-developer mailing list

Reply via email to