Liste des Groupes | Revenir à cl c |
On 27/08/2024 19:44, fir wrote:yes there were typos and mistakesfir wrote:>>on fictional snippet (probebly not working)though eventualy it canm be written shorter i guess
>
void draw_line( float x, float y, float x2, float y2, unsigned color)
{
float
wx=dist(x,x2),wy=dist(y,y2); int m=wx<wy?wx:wy;
float dx=wx/m,dy=wy/m;for(int
i=0;i<(int)m;i++)set_pixel(x+=dx,y+=dy,color);
}
>
thin skin
>
draw_line`x`y`x2`y2`color
{
`wx=dist x x2,`wy=dist y y2,`M=(wx<wy?wx!wy)
`dx=wx/m,`dy=wy/m, M'set_pixel x+=dx y+=dy color;
}
>
>
draw_line`x`y`x2`y2`color:
`m = min 'wx=abs x2-x 'wy=abs y2-y) ' set_pixel x+=wx/m y+=wy/m color;
;
>
not to say it lookin specially good but welll..
There are ways to have more compact syntax without it turning weird,
leaving out types, and using backtick separators and other strange
punctuation (or is that lone ')' a typo?).
>
Start with this version:
>
void draw_line( float x, float y, float x2, float y2, unsigned color)
{
float
wx=dist(x,x2),wy=dist(y,y2); int m=wx<wy?wx:wy;
float
dx=wx/m,dy=wy/m;for(inti=0;i<(int)m;i++)set_pixel(x+=dx,y+=dy,color);
}
>
For example:
>
void draw_line(f32 x, y, x2, y2; u32 colour) {
f32 wx = dist(x, y2), wy = dist(y, y2)
int m = min(wx, wy)
repeat m {
set_pixel(x += wx/m, y += wy/m, colour)
}
}
>
Summary:
>
- Allow shared types in parameter lists
- Auto semicolon insertion
- Built-in 'min/max' operators
- New repeat-n-times loop
- Shorter type names
Les messages affichés proviennent d'usenet.