public void Init(int rayCount, Type elementType, bool allowGluk) { RayCount = rayCount > 0 ? GetNewRayCount(rayCount) : Parameters.R.Next(_parameters.MinRayCount, _parameters.MaxRayCount); if (Parameters.R.Next(2) == 0 && RayCount % 2 == 0) { RayCount = RayCount / 2; } if (Parameters.R.Next(2) == 0 && RayCount % 2 == 0) { RayCount = RayCount / 2; } if (Parameters.R.Next(2) == 0 && RayCount % 2 == 0) { RayCount = RayCount / 2; } if (Parameters.R.Next(2) == 0 && RayCount % 2 == 0) { RayCount = RayCount / 2; } if (Parameters.R.Next(2) == 0 && RayCount % 2 == 0) { RayCount = RayCount / 2; } ДублируемыйЭлемент = СоздатьДублируемыйЭлемент(elementType, _parameters); ДублируемыйЭлемент.Init(RayCount); var minRadius = ДублируемыйЭлемент.MaxRadius + 2 * rayCount; var maxRadius = _parameters.PictureSide / 2 - minRadius; _maxRadius = 3 * Parameters.R.Next(minRadius, Math.Max(minRadius, maxRadius)) / 4f; if (allowGluk) { _rotationType = RotationType.Gluk; // Ну это пипец } else { _rotationType = RotationType.Simple; if (RayCount > PolarLimit) { if (Parameters.R.Next(4) == 0) { _rotationType = RotationType.Ray; } } } if (_rotationType == RotationType.Ray || _rotationType == RotationType.Gluk) { _a0 = (float)(360 * Parameters.R.NextDouble()); _a1 = MaxRotations * 2 * (float)(Parameters.R.NextDouble() - 0.5d); _r0 = (float)(_maxRadius * Parameters.R.NextDouble()) / 2; _polarRayCount = 4 + 2 * Parameters.R.Next(0, MaxPolarRayCount / 2); } }
public void Draw(Graphics gr) { try { ДублируемыйЭлемент.BeforeDraw(); var polarRayCount = _rotationType == RotationType.Ray ? _polarRayCount : 1; for (var j = 0; j < polarRayCount; j++) { var a = 360f * j / polarRayCount; for (var i = 0; i < RayCount; i++) { var t = GetPolarCoords(i); var angle = t.Key; var radius = t.Value; var oldMatrix = gr.Transform; try { gr.RotateTransform(a + angle); gr.TranslateTransform(radius, 0); var r = radius / _maxRadius; r = 0.1f + 0.9f * r; gr.ScaleTransform(r, r); ДублируемыйЭлемент.Draw(gr); } finally { gr.Transform = oldMatrix; } } } } finally { ДублируемыйЭлемент.AfterDraw(); } }
public void Change() { ДублируемыйЭлемент.Change(); }
public void Done() { ДублируемыйЭлемент.Done(); }