Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <867ch72cf1.fsf@linuxsc.com>
Deutsch   English   Français   Italiano  
<867ch72cf1.fsf@linuxsc.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: filling area by color atack safety
Date: Tue, 09 Apr 2024 01:00:34 -0700
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <867ch72cf1.fsf@linuxsc.com>
References: <ut3669$21eur$1@i2pn2.org> <86h6h3nvyz.fsf@linuxsc.com> <865xxiok09.fsf@linuxsc.com> <20240319131842.00002138@yahoo.com> <utbuk3$qed7$1@dont-email.me> <20240319191859.00004bc8@yahoo.com> <86bk79m10l.fsf@linuxsc.com> <20240324202758.00001b75@yahoo.com> <86frwfjs0n.fsf@linuxsc.com> <20240325012844.0000685b@yahoo.com> <20240326185218.00005397@yahoo.com> <86ttkoi28k.fsf@linuxsc.com> <20240330212657.000066e1@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 09 Apr 2024 08:00:36 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="47558c70f7e061adbec47d824d7ff660";
	logging-data="121718"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/IK6sWQ4W/ciTR9Y/pYm4F5Eq/ZzEnpSY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:o6roiIskWJHi6py7yHQ/OpYRwiA=
	sha1:ImdgBHJB9J9H4/Ekhul/Nva+R6s=
Bytes: 3632

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;
    }}
}