IntExtensionMethods.cs 850 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Copyright(c) Live2D Inc. All rights reserved.
  3. *
  4. * Use of this source code is governed by the Live2D Open Software license
  5. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
  6. */
  7. using UnityEngine;
  8. namespace Live2D.Cubism.Rendering.Masking
  9. {
  10. /// <summary>
  11. /// Extensions for <see cref="System.Int32"/>s.
  12. /// </summary>
  13. internal static class IntExtensionMethods
  14. {
  15. /// <summary>
  16. /// Checks whether an integer is a power of two.
  17. /// </summary>
  18. /// <param name="self">Value to check.</param>
  19. /// <returns><see langword="true"/> if power of two; <see langword="false"/> otherwise.</returns>
  20. public static bool IsPowerOfTwo(this int self)
  21. {
  22. return Mathf.ClosestPowerOfTwo(self) == self;
  23. }
  24. }
  25. }