Tim Jedlicka wrote:
> Martin Nordholts wrote:
>> 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:
>   [...]
> 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?

We can keep this on-list so other people can jump in the they wish to.

>From a performance point of view it is completely negligible to use an
if. The time it takes to do the actual rendering of a line is orders of
magnitude larger than having a conditional statement when calculating
what coordinates to use.

So the method of calculating what coordinates to use basically boils
down to using the method that gives the most readable code, and I would
say making use of an if is the most natural approach.

- Martin Nordholts

Gimp-developer mailing list

Reply via email to