Zentrische Streckung

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

Mogon

Betreff: Zentrische Streckung

BeitragSa, Feb 26, 2005 20:56
Antworten mit Zitat
Benutzer-Profile anzeigen
Mein neues Wunderwerk, das ich aufgrund unseres Themas im Matheunterricht gemacht habe: Die Zentrische Streckung!!!!

Den Streckfaktor k könnt Ihr nur im Quelltext ändern (Gaaaaanz oben mit dem Const das Ding da).

Dann setzt mit der Maus und den Tasten A,B,C und Z die Eckpunkte des Dreiecks und das Streckzentrum k.

Wenn Ihr wollt, könnt Ihr mit f12 einen Screenshot machen.

(Dieser Quelltext ist Public Domain. Very Happy )

Code: [AUSKLAPPEN]
Const k = 2


Graphics 1024,768

Repeat
   SetBuffer BackBuffer()
   ClsColor 255,255,255
   Cls
      
      Color 0,0,0
      
      Line MouseX()-5,MouseY(),MouseX()+5,MouseY()
      Line MouseX(),MouseY()-5,MouseX(),MouseY()+5
      
      If ax > 0 And bx > 0 And cx > 0 Then
         Line ax,ay,bx,by
         Line bx,by,cx,cy
         Line cx,cy,ax,ay
      EndIf
      
      Plot ax,ay
      Plot bx,by
      Plot cx,cy
      
      Line zx-2,zy,zx+2,zy
      Line zx,zy-2,zx,zy+2
      Plot zx,zy
      
      Text 0,0,"k = " +k
      Text 0,15,"a = "+ax+", " +ay
      Text 0,30,"b = "+bx+", " +by
      Text 0,45,"c = "+cx+", " +cy
      Text 0,60,"z = "+zx+", " +zy
      Text 0,75,"a' = " + asx+", "+asy
      
      Text ax-15,ay-15,"A"
      Text bx-15,by-15,"B"
      Text cx-15,cy-15,"C"
      Text zx-15,zy-15,"Z"
      
      Text asx-15,asy-15,"A'"
      Text bsx-15,bsy-15,"B'"
      Text csx-15,csy-15,"C'"
      
      asx = (ax - zx) *k +zx
      asy = (ay - zy) *k +zy
      
      bsx = (bx - zx) *k +zx
      bsy = (by - zy) *k +zy
      
      csx = (cx - zx) *k +zx
      csy = (cy - zy) *k +zy
      
      If asx > 0 And bsx > 0 And csx > 0 Then
         Line asx,asy,bsx,bsy
         Line bsx,bsy,csx,csy
         Line csx,csy,asx,asy
      EndIf
      
      Color 255,0,0
      
      Line ax,ay,asx,asy
      Line bx,by,bsx,bsy
      Line cx,cy,csx,csy      
      
      If asx > 0 And bsx > 0 And csx > 0 Then
         Line zx,zy,ax,ay
         Line zx,zy,bx,by
         Line zx,zy,cx,cy
      EndIf

      If KeyHit(30) Then
         ax = MouseX()
         ay = MouseY()
      EndIf
      If KeyHit(48) Then
         bx = MouseX()
         by = MouseY()
      EndIf
      If KeyHit(46) Then
         cx = MouseX()
         cy = MouseY()
      EndIf
      If KeyHit(21) Then
         zx = MouseX()
         zy = MouseY()
      EndIf
      
   Flip
Until KeyHit(1)

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group