Liste des Groupes | Revenir à l c |
fir wrote:i noticed it today that>>on fictional snippet (probebly not working)
>
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);
}
>
>
i thought on it yet and concluded code for that shopuld look more like
>
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
}
>
>
explanation:
>
point {ints x y}
>
this is structure "point" definition ,
ints is int[] but it also has named elements so int[0[ is x and int[1]
is y (such is very handy as structure may be seen as array and array as
structure.. so more fractal touch added (if it is proper name fractal
touch as maybe not im not sure)
>
line {points p q}
>
same this is structure named "line" defined
>
draw line(color c)
>
this is function header though line here is a type so its
a bit new in that aspect possibly
>
point a = p
>
instantiates point structure entity named a and copies p into it
>
as p is point in line and p is int2 type and int2 has defined assigning
to other int2 so this is automatic
>
int m = max abs(q-p)
>
same here q-p are int2 - int2 they are defined to retuirn int2
abs is defined on int2 to return two int2 values then max is defined
on int2 to return one int
>
m' is loop (loop m times)
this a+=(q-p)/m, is calculation, i know it will not work as
it shopuld work on floats but for simplicity of example as i was thinkin
on ints i will stay it with ints
>
overally this is kinda closer to C2 syntax i need
Les messages affichés proviennent d'usenet.