Changeset 9287


Ignore:
Timestamp:
2017-07-31 19:53:46 (2 years ago)
Author:
mianhayr
Message:
 
Location:
2017/30/MikkoH/Sq
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2017/30/MikkoH/Sq/Sq/Sq/Sq.cs

    r9286 r9287  
    66{ 
    77    List<Vector> ps, crc; 
    8     double rad = 50, radc = 0.01, mag = 4; 
     8    int dist = 10, pts = 150, mag = 100, minmag = 1, maxmag = 300, magc = 4, minrad = 1, maxrad = 100; 
     9    double rad = 50, radc = 0.01; 
    910 
    1011    public override void Begin() 
     
    1415        Level.Background.Color = Color.Black; 
    1516 
    16         ps = CreateSquare(100, 10); 
    17         crc = CreateCircle(50, 150); 
     17        ps = CreateSquare(mag, dist); 
     18        crc = CreateCircle(rad, pts); 
    1819    }    
    1920 
     
    3031 
    3132    // r = radius, n = number of pts 
    32     List<Vector> CreateCircle(int r, int n) 
     33    List<Vector> CreateCircle(double r, double n) 
    3334    { 
    3435        List<Vector> crc = new List<Vector>(); 
     
    5152        c.BrushColor = Color.Red; 
    5253 
     54        // draws and squeezes the square 
    5355        for (int i = 0; i < ps.Count; i++) 
    5456        { 
    5557            c.DrawLine(ps[i % ps.Count], ps[(i + ps.Count / 4) % ps.Count]); 
    56             ps[i] = Vector.FromLengthAndAngle(ps[i].Magnitude + mag, ps[i].Angle); 
    57             if (ps[i].Magnitude < 1 || ps[i].Magnitude > 300) 
    58                 mag = -mag; 
     58            ps[i] = Vector.FromLengthAndAngle(ps[i].Magnitude + magc, ps[i].Angle); 
     59            if (ps[i].Magnitude < minmag || ps[i].Magnitude > maxmag) 
     60                magc = -magc; 
    5961        } 
    6062 
    6163        c.BrushColor = Color.Blue; 
    6264 
     65        // draws and squeezes the circle 
    6366        for (int i = 0; i < crc.Count; i++) 
    6467        { 
    6568            c.DrawLine(crc[i % crc.Count], crc[(i + 2) % crc.Count]); 
    6669            crc[i] = new Vector(Math.Sin(i) * rad, Math.Cos(i) * rad); 
    67             if (rad < 1 || rad > 100) radc = -radc; 
     70            if (rad < minrad || rad > maxrad) radc = -radc; 
    6871            rad -= radc; 
    6972        } 
Note: See TracChangeset for help on using the changeset viewer.