GaussianGlow.qml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2021 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Graphical Effects module.
  7. **
  8. ** $QT_BEGIN_LICENSE:COMM$
  9. **
  10. ** Commercial License Usage
  11. ** Licensees holding valid commercial Qt licenses may use this file in
  12. ** accordance with the commercial license agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and The Qt Company. For licensing terms
  15. ** and conditions see https://www.qt.io/terms-conditions. For further
  16. ** information use the contact form at https://www.qt.io/contact-us.
  17. **
  18. ** $QT_END_LICENSE$
  19. **
  20. **
  21. **
  22. **
  23. **
  24. **
  25. **
  26. **
  27. **
  28. **
  29. **
  30. **
  31. **
  32. **
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ****************************************************************************/
  39. import QtQuick 2.12
  40. import QtGraphicalEffects.private 1.12
  41. Item {
  42. id: rootItem
  43. property variant source
  44. property real radius: 0.0
  45. property int maximumRadius: 0
  46. property real spread: 0.0
  47. property color color: "white"
  48. property bool cached: false
  49. property bool transparentBorder: false
  50. SourceProxy {
  51. id: sourceProxy
  52. input: rootItem.source
  53. sourceRect: rootItem.transparentBorder ? Qt.rect(-1, -1, parent.width + 2.0, parent.height + 2.0) : Qt.rect(0, 0, 0, 0)
  54. }
  55. ShaderEffectSource {
  56. id: cacheItem
  57. anchors.fill: shaderItem
  58. visible: rootItem.cached
  59. smooth: true
  60. sourceItem: shaderItem
  61. live: true
  62. hideSource: visible
  63. }
  64. GaussianDirectionalBlur {
  65. id: shaderItem
  66. x: transparentBorder ? -maximumRadius - 1 : 0
  67. y: transparentBorder ? -maximumRadius - 1 : 0
  68. width: horizontalBlur.width
  69. height: horizontalBlur.height
  70. horizontalStep: 0.0
  71. verticalStep: 1.0 / parent.height
  72. source: horizontalBlur
  73. radius: rootItem.radius
  74. maximumRadius: rootItem.maximumRadius
  75. transparentBorder: rootItem.transparentBorder
  76. enableColor: true
  77. color: rootItem.color
  78. spread: rootItem.spread
  79. }
  80. GaussianDirectionalBlur {
  81. id: horizontalBlur
  82. width: transparentBorder ? parent.width + 2 * maximumRadius + 2 : parent.width
  83. height: transparentBorder ? parent.height + 2 * maximumRadius + 2 : parent.height
  84. horizontalStep: 1.0 / parent.width
  85. verticalStep: 0.0
  86. source: sourceProxy.output
  87. radius: rootItem.radius
  88. maximumRadius: rootItem.maximumRadius
  89. transparentBorder: rootItem.transparentBorder
  90. visible: false
  91. }
  92. }