Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Christmas puzzle
Message
 
À
24/12/2003 10:59:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00861878
Message ID:
00861946
Vues:
25
Kooool!

>Viv,
>
>Assuming that there are some graphic bits that can stand alone, is there any chance of you posting some GDI code? I would love to see it in action.
>
>This should generate the polygon you wanted.
>
>
>************************************************************
>*
>* Get x,y co-ords of shape fitting 2 concentric arcs
>* between two angles.
>*
>* Assume :-
>*   Centre of circle is at 0,0
>*   Arc is drawn clockwise from Angle1 to Angle2
>*   Angles are measured anticlockwise from +ve x axis
>*   The arcs are substituted by lnNumSteps straight lines
>*
>************************************************************
>
>* Test the function
>=GetCoords(60, 0, 50, 100, 100)
>=GetCoords(135, 30, 50, 100, 100)
>=GetCoords(300, 30, 50, 100, 100)
>=GetCoords(420, 300, 50, 100, 100)
>
>FUNCTION GetCoords
>LPARAMETERS lnDegAngle1, lnDegAngle2, lnRadius1, lnRadius2, lnNumSteps
>
>   * Improve the accuracy
>   lnOldDecimals = SET('Decimals')
>   SET DECIMALS TO 10
>
>   * Store for coordinates, x in [?,1], y in [?,2]
>   DIMENSION laCoords(4 + 2*lnNumSteps, 2)
>
>   * Conversion factor from degrees to radians
>   lnDeg2Rad   = 2 * 3.14159265358979 / 360
>   lnRadAngle1 = lnDegAngle1 * lnDeg2Rad
>   lnRadAngle2 = lnDegAngle2 * lnDeg2Rad
>
>   * Arc endpoint values placed in sequence in array
>   laCoords[1,1] = lnRadius1*COS(lnRadAngle1)
>   laCoords[1,2] = lnRadius1*SIN(lnRadAngle1)
>   laCoords[2,1] = lnRadius2*COS(lnRadAngle1)
>   laCoords[2,2] = lnRadius2*SIN(lnRadAngle1)
>   laCoords[lnNumSteps + 2 + 1,1] = lnRadius2*COS(lnRadAngle2)
>   laCoords[lnNumSteps + 2 + 1,2] = lnRadius2*SIN(lnRadAngle2)
>   laCoords[lnNumSteps + 2 + 2,1] = lnRadius1*COS(lnRadAngle2)
>   laCoords[lnNumSteps + 2 + 2,2] = lnRadius1*SIN(lnRadAngle2)
>
>   * Calc angle increments for lnNumSteps
>   lnAngleInc = (lnRadAngle1 - lnRadAngle2)/lnNumSteps
>
>   * Coordinates for the arcs
>   FOR t = 1 TO lnNumSteps
>      * Coordinates for the first arc, going clockwise
>      laCoords[t+2, 1] = lnRadius2*COS(lnRadAngle1 - t*lnAngleInc)
>      laCoords[t+2, 2] = lnRadius2*SIN(lnRadAngle1 - t*lnAngleInc)
>      * Coordinates for the second arc, going anticlock
>      laCoords[5 + 2*lnNumSteps - t, 1] = lnRadius1*COS(lnRadAngle1 - t*lnAngleInc)
>      laCoords[5 + 2*lnNumSteps - t, 2] = lnRadius1*SIN(lnRadAngle1 - t*lnAngleInc)
>   ENDFOR
>
>   * Set up to draw
>   CLEAR
>   lnRadius  = MAX(lnRadius1, lnRadius2)
>   lnExtra   = 20
>   lnOffSetX = lnRadius + lnExtra + 30
>   lnOffSetY = lnOffSetX
>
>   * Draw axes
>   _SCREEN.Line(lnOffSetX - lnRadius - lnExtra,;
>                lnOffSetY                     ,;
>                lnOffSetX + lnRadius + lnExtra,;
>                lnOffSetY)
>    _SCREEN.Line(lnOffSetX                     ,;
>                lnOffSetY - lnRadius - lnExtra,;
>                lnOffSetX                     ,;
>                lnOffSetY + lnRadius + lnExtra)
>
>   * Draw polygon
>   lnNumLines = ALEN(laCoords, 1) - 1
>   FOR t = 1 TO lnNumLines
>       _SCREEN.Line(laCoords[t,   1] + lnOffSetX, lnOffSetY - laCoords[t,   2] ,;
>                    laCoords[t+1, 1] + lnOffSetX, lnOffSetY - laCoords[t+1, 2])
>   ENDFOR
>
>   * Restore old SETs
>   SET DECIMALS TO (lnOldDecimals)
>
>   WAIT WINDOW
>
>ENDFUNC
>
Imagination is more important than knowledge
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform