• [^] # Re: Pas vraiment le C

    Posté par . En réponse au message Graphisme retro en console. Évalué à 3. Dernière modification le 23 novembre 2025 à 22:16.

    effectivement tous les languages n'ont pas forcément accès à des manipulations de graphisme avancés (pixels, gui etc)

    En FORTH, on a la commande x y AT-XY pour afficher des caractères à un endroit donné de la console.

    Je me suis amusé a réaliser un petit programme similaire pour afficher une sinusoïde, cela fonctionne avec ueforth et gforth, ce sont les commentaires qui prennent le plus de place :

    : sinusoide 
    112 1 do  \ counter loop from 1 to 112
    i 
    dup  \ we duplicate the counter value to reuse it
    3 *  \ we scale a bit the value to display it better
    s>f \ we convert the integer to real
    fsin  \ we calculate the sinus in radian
     \ degree = radian x 180 / pi
    180e f* pi f/  \ we convert from radian to degree
    10e f*  f>s \ we increase the precision and convert back to integer
    10 /  \ we move back the fixed point
    60 +  \ we shift the y axis 60 pixels below to fit the terminal
    5 /  \ we refine the displayed data
    \ . . cr \ uncomment to display the calculated values (and comment the line below)
    at-xy 42 emit  \ emit a star * at the coordinates calculated above
    loop  
    ;
    page  \ clear the page
    sinusoide 
    0 80 at-xy  \ we put the prompt under the graph
    bye  \ exit

    et cela affichera

     * * * * * * * * * *
     * * * * * * * *
     * * * * * *
     * * * *
     * * * *
     * * * *
     * * * *
     * * *
     * * *
     * * *
     * * *
     * ** *
     * *
     * * * *
     * * *
     * * *
     * * * *
     * * *
     * * * *
     * * * *
     * * * * *
     * * * * *
     * * * * * * * *
     * * * * * * * * * *
    

    "Ce n'est pas à l'état de tout savoir sur ses citoyens, mais au citoyen de tout savoir sur l'état."