electron_smooth_round_rect.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2024 Salesforce, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_RENDERER_API_ELECTRON_SMOOTH_ROUND_RECT_H_
  5. #define ELECTRON_SHELL_RENDERER_API_ELECTRON_SMOOTH_ROUND_RECT_H_
  6. #include "third_party/skia/include/core/SkPath.h"
  7. namespace electron {
  8. // Draws a rectangle that has smooth round corners for a given "smoothness"
  9. // value between 0.0 and 1.0 (representing 0% to 100%).
  10. //
  11. // The smoothness value determines how much edge length can be consumed by each
  12. // corner, scaling with respect to that corner's radius. The smoothness will
  13. // dynamically scale back if there is not enough edge length, similar to how
  14. // the corner radius backs off when there isn't enough edge length.
  15. //
  16. // Each corner's radius can be supplied independently. Corner radii are expected
  17. // to already be balanced (Radius1 + Radius2 <= Length, for each given side).
  18. //
  19. // Elliptical corner radii are not currently supported.
  20. SkPath DrawSmoothRoundRect(float x,
  21. float y,
  22. float width,
  23. float height,
  24. float smoothness,
  25. float top_left_radius,
  26. float top_right_radius,
  27. float bottom_right_radius,
  28. float bottom_left_radius);
  29. } // namespace electron
  30. #endif // ELECTRON_SHELL_RENDERER_API_ELECTRON_SMOOTH_ROUND_RECT_H_