Skip to main content
Inspiring
September 2, 2016
Question

Drawing a straight line produces artefacts

  • September 2, 2016
  • 1 reply
  • 1074 views

I'm using the algorithm y = mx+c and am receiving seemingly random artefacts in my line which I'm not really sure how to start debugging. Does anyone have any ideas? Two pixels in the line are gone and one is in the wrong position. Thanks.

This topic has been closed for replies.

1 reply

françois leroy
Inspiring
September 2, 2016

Hi,

are you using an iteration suite? Or do you access ram directly?

If you're working with ram, you probably need to use PF_ABORT and / or PF_PROGRESS to handle interruptions.

If you're using iteration suites, AE will do it for you.

Cheers,

François

Inspiring
September 4, 2016

Hi Francois

I didn't know you could access ram directly, so I am using the iteration suite. Each pixel is checked against my algorithm to determine if it's black or white.

françois leroy
Inspiring
September 15, 2016

Hi Francois

I tried using: FP_FpLong x0 = xL to have the x coord as a double rather than a long, but the error persists. Very peculiar is the fact that every time I purge the memory, the artefacts appear on different pixels! I'm stumped.

Initially I hired a programmer to write this plugin for me, and now I'm in the process of recreating it myself. In his version, he has x and y coords as this:

// rasterization point

    PF_FpLong x0 = FIX_2_FLOAT(xL << 16);

    PF_FpLong y0 = FIX_2_FLOAT(yL << 16);

I'm not sure why he has it written as that, as it seems to produce the same result as mine.


the FIX_2_FLOAT() MACRO is there to convert Fixed point values (here probably a point parameter?) to flaot point value.

There's something you can try:

_if you write into the output directly, try to clear it before (ERR(PF_FILL(     output, null, null));)

_in your iteration function, do you draw the line only, or do you fill the rest with black (or transparent)? I think your code should look like this:

if (y = mx+c) {

     fill with white

} else {

     fill with black (or transparent or whatever)

}

If it still doesn't work, can you post a bit more of your code? It would help finding the solution...

Cheers,

François