protected override void OnLoad(EventArgs e) { GL.ClearColor(Color.Wheat); Rescale(); _defaultDrawList = PythagorasSets.GetSets(DefaultIterations, SquareSize).SelectMany(i => i).ToList(); CalcData(); }
private void CalculateVisiblePythagorasSetsThread() { if (_iterations < DefaultIterations) { _calculatingVisiblePythagorasSetsThread = null; return; } /* * Find visible squares at the Nth iteration. */ List <Pythagoras> current = PythagorasSets.GetSet(DefaultIterations - 1, SquareSize) .Where( py => py.LeftSquare.Any(p => _viewport.IsNear(p, 50 / _scale)) || py.RightSquare.Any(p => _viewport.IsNear(p, 50 / _scale))) .ToList(); for (int i = DefaultIterations; i < _iterations; i++) { var next = current.SelectMany(p => p.Next()); /* * .ToArray to make sure .Where ran before we lock the list. */ Pythagoras[] visible = next.Where(p => p.LeftSquare.Any(_viewport.Contains) || p.RightSquare.Any(_viewport.Contains)) .ToArray(); lock (_drawListLocker) { _drawList.AddRange(visible); } /* * Keep iteration for next iteration's reference. */ current = next.ToList(); } }