word on this example

Liste des GroupesRevenir à cl c  
Sujet : word on this example
De : fir (at) *nospam* grunge.pl (fir)
Groupes : comp.lang.c
Date : 29. Aug 2024, 13:25:50
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <e3cda7cd9313843a1dd37873ced4c77c05e49745@i2pn2.org>
User-Agent : Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
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

Date Sujet#  Auteur
29 Aug 24 * word on this example5fir
29 Aug 24 +- Re: word on this example1fir
31 Aug 24 `* Re: word on this example3fir
31 Aug 24  `* Re: word on this example2fir
31 Aug 24   `- Re: word on this example1fir

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal