Deutsch   English   Français   Italiano  
<e3cda7cd9313843a1dd37873ced4c77c05e49745@i2pn2.org>

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

Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail
From: fir <fir@grunge.pl>
Newsgroups: comp.lang.c
Subject: word on this example
Date: Thu, 29 Aug 2024 13:25:50 +0200
Organization: i2pn2 (i2pn.org)
Message-ID: <e3cda7cd9313843a1dd37873ced4c77c05e49745@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Aug 2024 11:25:55 -0000 (UTC)
Injection-Info: i2pn2.org;
	logging-data="133239"; mail-complaints-to="usenet@i2pn2.org";
	posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
X-Spam-Checker-Version: SpamAssassin 4.0.0
Bytes: 3483
Lines: 110

sorry i start thread on it (as its my inner work not general c maybe,
though some could comment) but this example has some new ideas and
sometimes i tend to forget some things that i deeply not worked
and this would be pity to forget that

and here by chance some things appeared clean

point {ints x y}
line {points p q}
draw line(color c)
{
    point a = p
    int m = max abs(q-p) ' a+=(q-p)/m, Setpixel a, c
}

those structure definitions are neat (first tiem i see this)
it looks almost finallly good and it resolves some problems
(what problems like
int a b c, i didnt slightly liked now ints a b c removes that
and also makes this structure array nice mixup, gods, thats good, clean 
as fuk)

draw line(color c)

also neat idea , in fact this draw is a method of line
but how you could write with older ideas

line
{
  points p q

   draw(color c)
  {
    point a = p
    int m = max abs(q-p) ' a+=(q-p)/m, Setpixel a, c
  }
}

line a = {10,10,200,100};
a draw(0xcccccc) //used to look ok but now sucks

it also resolves this great problem method may have
couple of parents not only one

becouse draw here may be seen as a child of both line and color

instead of
draw line(color c)
{
    point a = p
    int m = max abs(q-p) ' a+=(q-p)/m, Setpixel a, c
}


draw color line  //here both color and line are typenames
{
    point a = p  //fields of both color and lien are accsible here
    int m = max abs(q-p) ' a+=(q-p)/m, Setpixel a, rgb //say rgb is 
field of color
}

calling would be

draw  0xffffff {{10,10}, {100,200}}

or

line l {{10,10}, {100,200}}
color c 0xffffff

draw  c l

if soem mises names could be added cast or something
draw (line) l (color) c

i dont know, at least seems intresting imo

some could say that display should be also added becouse
Setpixel must come from something so it would be




color (chars r g b a)
point {ints x y}
line {points p q}
display(ins w h) { w h 4 chars map } // "100 ints t" is int t[100]

display set point with color {
   map[y][x][0] = color.r
   map[y][x][1] = color.g
   map[y][x][2] = color.b
   //assumming array acces is like that (which is not optimal imo) and i 
want to explicitely write which byte takes r g b

  // may go automatic map[y][x] = color //may omit map probably wrting 
[y][x] = color
}

line l  {10,10,100,200}
color c  {30 40 50 0}
display d(640 480)

draw color line on display
{
    point a = p       //could also write line.q instead q optionally etc
    int m = max abs(q-p) ' a+=(q-p)/m, set a with color
}


maybe not fuly right but probably something this way