private void OnPenDraw() { // Clear if needed if (willClearFrames > 0) { willClearFrames--; if (willClearFrames == 0) { pen.DrawRect(GetViewportRect(), clearColor); } } DrawFunction?.Invoke(pen); }