Seite 1 von 1

Re: dreiecke in bildern programmieren ?

Verfasst: Dienstag 1. Mai 2012, 20:03
von kloed
danke schön ! :)

ich habe es jetzt endlich hinbekommen juhuuu!

Re: dreiecke in bildern programmieren ?

Verfasst: Mittwoch 2. Mai 2012, 20:16
von BlackJack
@kloed: Glückwunsch! :-)

Ich hatte das zwischenzeitlich mal in Forth implementiert:

Code: Alles auswählen

\ Flag of the Bahamas as PPM.

800 constant width
width 2/  constant height

: black ( -- ) ." 0 0 0" ;
: aquamarine ( -- ) ." 102 205 170" ;
: gold ( -- ) ." 255 215 0" ;

: main ( -- )
    ." P3 " width . height . ." 255" cr
    height 6 /  height 2/
    height 0 ?do
        width 0 ?do
            dup j - abs         \ distance to horziontal middle
            2dup -  dup 2/ +  i >=
                if black
                else dup 3 pick <=  if gold else aquamarine then
                then space drop
        loop cr
    loop 2drop ;

main
bye
Die Breite des Dreiecks stimmt nicht ganz weil ich es einfach/ganzzahlig belassen wollte.