Re: filling area by color atack safety

Liste des GroupesRevenir à cl c 
Sujet : Re: filling area by color atack safety
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.c
Date : 09. Apr 2024, 09:00:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <867ch72cf1.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Michael S <already5chosen@yahoo.com> writes:

On Sat, 30 Mar 2024 00:54:19 -0700
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
[...]
Something that would help is to have a library of test cases,
by which I mean patterns to be colored, so that a set of
methods could be tried, and timed, over all the patterns in
the library.  Do you have something like that?  So far all
my testing has been ad hoc.
>
I am not 100% sure about the meaning of 'ad hoc', but I'd guess
that mine are ad hoc too.  Below are shapes that I use apart from
solid rectangles.  I run them at 5 sizes: 25x19, 200x200,
1280x720, 1920x1080, 3840x2160.  That is certainly not enough for
correction tests, but feel that it is sufficient for speed tests.
>
[code]

I got these, thank you.

Here is a pattern generating function I wrote for my own
testing.  Disclaimer: slightly changed from my original
source, hopefully any errors inadvertently introduced can
be corrected easily.  Also, it uses the value 0 for the
background and the value 1 for the pattern to be colored.

#include <math.h>
#include <stddef.h>
#include <string.h>

typedef unsigned char Pixel;

extern void
ellipse_with_hole( Pixel *field, unsigned w, unsigned h ){
    size_t i, j;
    double wc = w/2, hc = h/2;

    double a = (w > h ? wc : hc) -1;
    double b = (w > h ? hc : wc) -1;

    double b3 = 1+6*b/8;
    double radius = b/2.5;
    double cx = w > h ? wc   : b3+1;
    double cy = w > h ? b3+1 : hc;

    double focus = sqrt( a*a - b*b );
    double f1x = w > h ? wc - focus : wc;
    double f1y = w > h ? hc : hc - focus;
    double f2x = w > h ? wc + focus : wc;
    double f2y = w > h ? hc : hc + focus;

    memset( field, 0, w*h );

    for(  i = 0;  i < w;  i++  ){
    for(  j = 0;  j < h;  j++  ){
        double dx = i - cx, dy = j - cy;
        double r2 = radius * radius;
        if(  dx * dx + dy*dy <= r2  )  continue;
        double dx1 = i - f1x, dy1 = j - f1y;
        double dx2 = i - f2x, dy2 = j - f2y;
        double sum2 = a*2;
        double d1 = sqrt( dx1*dx1 + dy1*dy1 );
        double d2 = sqrt( dx2*dx2 + dy2*dy2 );
        if(  d1 + d2 > 2*a  )  continue;
        field[ i+j*w ] = 1;
    }}
}

Date Sujet#  Auteur
24 Mar 24 * Re: filling area by color atack safety16Michael S
24 Mar 24 `* Re: filling area by color atack safety15Tim Rentsch
24 Mar 24  +- Re: filling area by color atack safety1Chris M. Thomasson
24 Mar 24  `* Re: filling area by color atack safety13Michael S
26 Mar 24   +* Re: filling area by color atack safety4Michael S
30 Mar 24   i`* Re: filling area by color atack safety3Tim Rentsch
30 Mar 24   i `* Re: filling area by color atack safety2Michael S
9 Apr 24   i  `- Re: filling area by color atack safety1Tim Rentsch
29 Mar 24   `* Re: filling area by color atack safety8Tim Rentsch
29 Mar 24    `* Re: filling area by color atack safety7Michael S
30 Mar 24     +* Re: filling area by color atack safety5Tim Rentsch
30 Mar 24     i`* Re: filling area by color atack safety4Michael S
31 Mar 24     i +* Re: filling area by color atack safety2Michael S
9 Apr 24     i i`- Re: filling area by color atack safety1Tim Rentsch
9 Apr 24     i `- Re: filling area by color atack safety1Tim Rentsch
30 Mar 24     `- Re: filling area by color atack safety1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal