public Web(Graphics gfx, PointF centre, WebSpiral spiral, params PointF[] strands) { this.gfxPallete = gfx; this.Centre = centre; this.Spiral = spiral; this.RadialThreads = strands.Select(s => new Strand(this.Centre, s)).ToArray(); foreach (PointF strand in strands) { gfx.DrawLine(Silk, this.Centre, strand); } PointF lastPoint = new PointF(centre.X, centre.Y); float distancePerStrand = this.Spiral.LoopInterval / Convert.ToSingle(this.RadialThreads.Length); float length = distancePerStrand; for (int i = 0; i < this.Spiral.LoopCount; ++i) { for (int j = 0; j < this.RadialThreads.Length; ++j) { PointF nextPoint = this.RadialThreads[j].PointToLength(length); length += distancePerStrand; gfx.DrawLine(Silk, lastPoint, nextPoint); lastPoint = nextPoint; } } }
public Web(Graphics gfx, PointF centre, WebSpiral spiral, int strandsCount) { PointF northPoint = new PointF(gfx.DpiX / 2, 0); PointF eastPoint = new PointF(gfx.DpiX, gfx.DpiY / 2); PointF southPoint = new PointF(gfx.DpiX / 2, gfx.DpiY); PointF westPoint = new PointF(0, gfx.DpiY / 2); List <PointF> strands = new List <PointF>(); double angleInterval = 360.0 / strandsCount; double targetAngle = 360.0 - (angleInterval / 2.0); for (double currentAngle = spiral.AngleStart + (angleInterval / 2.0); currentAngle != targetAngle; currentAngle += angleInterval) { float x = 0; float y = 0; double adjustedAngle = currentAngle % 45.0; if (currentAngle < 45 || currentAngle > 315) { x = gfx.DpiX; y = ((float)Math.Tan(adjustedAngle) * gfx.DpiY); } else if (currentAngle > 135 && currentAngle < 225) { x = 0; y = gfx.DpiY - ((float)Math.Tan(adjustedAngle) * gfx.DpiY); } else if (currentAngle > 45 && currentAngle < 135) { x = gfx.DpiX - ((float)Math.Tan(adjustedAngle) * gfx.DpiX); y = 0; } else if (currentAngle > 225 && currentAngle < 315) { x = ((float)Math.Tan(adjustedAngle) * gfx.DpiX); y = gfx.DpiY; } else { switch (currentAngle) { case 45: x = gfx.DpiX; y = 0; break; case 135: x = 0; y = 0; break; case 225: x = 0; y = gfx.DpiY; break; case 315: x = gfx.DpiX; y = gfx.DpiY; break; } } } }