home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
xfedor.zip
/
XFree86
/
src
/
xfedor
/
ed_beziers.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-02
|
2KB
|
99 lines
/* Copyright 1989 GROUPE BULL -- See licence conditions in file COPYRIGHT */
#include <stdio.h>
#include <math.h>
#include "couche.h" /* myEvent */
#define round(f) ((((int)((f)*100)-((int)(f)*100))<50)?((int)(f)):((int)(f)+1))
static tracercourbe(x0,y0,x1,y1,x2,y2,x3,y3)
int x0,y0,x1,y1,x2,y2,x3,y3 ;
{
float t;
float unmoinst;
float t2,t3;
float nbp; /*nombre de Points a calculer */
float lepas;
float pfx,pfy;
nbp = (float) (
sqrt((float)((x1 - x2)*(x1 - x2) +
(y1 - y2)*(y1 - y2)))+
sqrt((float)((x3 - x2)*(x3 - x2) +
(y3 - y2)*(y3 - y2)))+
sqrt((float)((x1 - x0)*(x1 - x0) +
(y1 - y0)*(y1 - y0)))) ;
lepas = (float) 1 / nbp;
for (t = 0; t <= 1; t += lepas)
{unmoinst = 1-t;
t2 = t*t;
t3 = t2*t;
pfx = ((unmoinst)*(unmoinst)*(unmoinst)* x0 +
3*t*(unmoinst)*(unmoinst)* x1 +
3*t2*(unmoinst)* x2 + t3* x3 );
pfy = ((unmoinst)*(unmoinst)*(unmoinst)* y0 +
3*t*(unmoinst)*(unmoinst)* y1 +
3*t2*(unmoinst)* y2 + t3* y3 );
Adjpoint(round(pfx),round(pfy));
}
Aff_all() ;
CarFen();
}
Autom_bez (pev)
myEvent * pev ;
{
static numpoint ;
static int x0,y0,x1,y1,x2,y2,x3,y3 ;
switch (pev->type) {
case EnterZone : Afficher_boutons("POINT","POINT");
numpoint = 1 ;
break ;
case ButtonPressed : switch (numpoint) {
case 1 : x0 = convert(pev->x) ;
y0 = convert(pev->y) ;
numpoint ++ ;
Invpoint(x0,y0) ;
break ;
case 2 : x1 = convert(pev->x) ;
y1 = convert(pev->y) ;
numpoint ++ ;
Invpoint(x1,y1);
break ;
case 3 : x2 = convert(pev->x) ;
y2 = convert(pev->y) ;
numpoint ++ ;
Invpoint(x2,y2) ;
break ;
case 4 : x3 = convert(pev->x) ;
y3 = convert(pev->y) ;
Invpoint(x0,y0) ;
Invpoint(x1,y1) ;
Invpoint(x2,y2) ;
Dodo();
tracercourbe(x0,y0,x1,y1,
x2,y2,x3,y3);
numpoint = 1 ;
break ;
}
break ;
case ButtonReleased : break ;
case MoveMouse : break ;
case CloseWindow : break ;
case LeaveZone : Afficher_boutons("","");
Afficher_numview(-1,-1) ; /* restaure le gris */
switch (numpoint) {
case 2 : Invpoint(x0,y0) ; break ;
case 3 : Invpoint(x0,y0) ;
Invpoint(x1,y1) ; break ;
case 4 : Invpoint(x0,y0) ;
Invpoint(x1,y1) ;
Invpoint(x2,y2) ; break ;
default : break ;
}
break ;
}
}