`BoxShadow`: Accept values for vertical and horizontal `spread_radius` (#8138)

* Accept values for vertical and horizontal `spread_radius`

* fix image

* update docs
This commit is contained in:
Dexer 2023-02-22 17:04:11 -03:00 committed by GitHub
parent 7733a20b30
commit f222bfb8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 151 additions and 145 deletions

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -25,9 +25,9 @@
inkscape:deskcolor="#505050"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="1.3504605"
inkscape:cx="397.27189"
inkscape:cy="176.60642"
inkscape:zoom="1.3812695"
inkscape:cx="470.94358"
inkscape:cy="149.50015"
inkscape:window-width="1920"
inkscape:window-height="991"
inkscape:window-x="-9"
@ -217,7 +217,15 @@
width="52.916664"
height="39.687496"
x="1772.6295"
y="-94.129494" /></clipPath></defs><g
y="-94.129494" /></clipPath><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath890"><rect
style="fill:#f2f2f2;stroke-width:0.529169;paint-order:fill markers stroke"
id="rect892"
width="52.916626"
height="39.687496"
x="1916.0824"
y="-108.74129" /></clipPath></defs><g
inkscape:label="Camada 1"
inkscape:groupmode="layer"
id="layer1"
@ -228,6 +236,15 @@
height="78.908119"
x="1786.7321"
y="-206.03146" /><image
width="81.756248"
height="69.320831"
preserveAspectRatio="none"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATUAAAEGCAYAAAAE8QIHAAAABHNCSVQICAgIfAhkiAAABE9JREFU eJzt2V1qIkEUgNEykbSa3WT/a8huonYw6XmaZjI/MDADxi/nwKVfC8GPutRmWZZlAETcXfsAAP+T qAEpogakiBqQImpAiqgBKaIGpIgakCJqQIqoASmiBqSIGpAiakCKqAEpogakiBqQImpAiqgBKaIG pIgakCJqQIqoASmiBqSIGpAiakCKqAEpogakiBqQImpAiqgBKaIGpIgakLK99gHGGOPp6Wlst9sx TdOYpmnsdrux3+/XORwO4/HxcRwOhw+z3+/HbrdbZ5qm8fDwsM52u13n/v5+3N3d/TKbzWb9jjHW L1/bsizr9/39ff3+PG9vb+Nyuazz+vq6zjzP43w+r3M6ncbxePwwLy8v43g8jtPptM75fB7zPI95 nsflchnPz89X/jVuy6eI2mcjbF/b96Bxm6yfQIqoASnWzz+wgn5NVs/b56YGpIgakGL9/EvW0Sbr Zo+bGpAiakCKqAEpogakiBqQ4vXzH3kVvQ1eOb8ONzUgRdSAFFEDUkQNSBE1IEXUgBRRA1JEDUgR NSBF1IAUUQNSRA1IETUgRdSAFFEDUkQNSBE1IEXUgBRRA1JEDUgRNSBF1IAUUQNSRA1IETUgRdSA FFEDUkQNSBE1IEXUgBRRA1JEDUgRNSBF1IAUUQNSRA1IETUgRdSAFFEDUkQNSBE1IEXUgBRRA1JE DUgRNSBF1IAUUQNSRA1IETUgRdSAFFEDUkQNSBE1IEXUgBRRA1JEDUgRNSBF1IAUUQNSRA1IETUg RdSAFFEDUkQNSBE1IEXUgBRRA1JEDUgRNSBF1IAUUQNSRA1IETUgRdSAFFEDUkQNSBE1IEXUgBRR A1JEDUgRNSBF1IAUUQNSRA1IETUgRdSAFFEDUkQNSBE1IEXUgBRRA1JEDUgRNSBF1IAUUQNSRA1I ETUgRdSAFFEDUkQNSBE1IEXUgBRRA1JEDUgRNSBF1IAUUQNSRA1IETUgRdSAFFEDUkQNSBE1IEXU gBRRA1JEDUgRNSBF1IAUUQNSRA1IETUgRdSAFFEDUrbXPsCtW5bl2kcAfuCmBqSIGpAiakCKqAEp ogakeP38S1454Ta4qQEpogakWD//wLoJt8lNDUgRNSDF+vkbVk+4XZvFPxgIsX4CKaIGpIgakCJq QIqoASmiBqSIGpAiakCKqAEpogakiBqQImpAiqgBKaIGpIgakCJqQIqoASmiBqSIGpAiakCKqAEp ogakiBqQImpAiqgBKaIGpIgakCJqQIqoASmiBqSIGpAiakCKqAEpogakiBqQImpAiqgBKaIGpIga kCJqQIqoASmiBqSIGpAiakCKqAEpogakiBqQImpAiqgBKaIGpIgakCJqQIqoASmiBqSIGpAiakCK qAEpogakiBqQImpAiqgBKaIGpIgakCJqQIqoASmiBqSIGpAiakCKqAEpogakiBqQImpAiqgBKaIG pIgakCJqQIqoASmiBqR8A/9OiwnoFFQQAAAAAElFTkSuQmCC "
id="image886"
x="1907.3312"
y="-117.38532"
clip-path="url(#clipPath890)"
transform="translate(56.347978,-82.746641)" /><image
width="98.160408"
height="86.518745"
preserveAspectRatio="none"
@ -245,63 +262,40 @@
x="1854.6449"
y="-112.38065"
clip-path="url(#clipPath3036)"
transform="translate(12.540657,-95.216843)" /><image
width="91.016663"
height="82.814575"
preserveAspectRatio="none"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVgAAAE5CAYAAADVxDi/AAAABHNCSVQICAgIfAhkiAAABltJREFU eJzt3UFy2koUQFGJZBNZRva/oHgT0H/wS1XEBbENukiYc2Zk1IPHTftJceYxxpgAWN1h6wMAfFcC CxARWICIwAJEBBYgIrAAEYEFiAgsQERgASICCxARWICIwAJEBBYgIrAAEYEFiAgsQERgASICCxAR WICIwAJEBBYgIrAAEYEFiAgsQERgASICCxARWICIwAJEBBYgIrAAEYEFiAgsQERgASICCxARWICI wAJEBBYgIrAAEYEFiAgsQERgASICCxARWICIwAJEBBYgIrAAEYEFiAgsQERgASICCxARWICIwAJE BBYgIrAAEYEFiAgsQERgASICCxARWICIwAJEBBYgIrAAEYEFiAgsQERgASICCxARWICIwAJEBBYg 8nPrA+zR29vb9OfPn62PAbv0+/fvrY/wNAT2gre3t2me5+lwOEzzPG99HNjcGGM6nU5bH+PpCOwV h8Nh+vHjx3Q42KLAEleR/RqB/YclsvM8u8nyksYY0xhjmqZpOh6PG5/m+QjsFUtU53l2k+VlnU6n 6Xg8umTcSGA/sOxi7WN5NcvN1VrgdgL7SR568Uo81FqHwH6ByPIKxHU9AvtJ5zvZZR8rtHwn5ysB O9d1COwNzmML38X5GwOsQ2Bv9D6y8zxPYwzR5Sm8D+nyWWDXJbB3uBRZeAbnsyquHYG9k3UBz0xc WwK7AoHlmYlrR2BXJLI8E2HtCezK7GPZMyuBxxLYlbx/2CWwbGl5o+XSmy3nfya0Lb/BZGXiyh5c +0nKfD6WG2zIMLMX/hHBNgQ28j6uQssWlqhaCWzDiuABxJWtmL1tCSxAxIrgwf51o/C7DFiLVcA+ uME+0EfxFFfWYpb2wQ12A4afktvrfrjBAkQEFiAisAARO9idsJflFvat++YGuwPiyq3Mzr4JLEBE YAEiAgsQ8ZBrx+zXOOeB1vNxgwWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgIL EBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFY gIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjA AkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQE FiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAi sAARgQWICCxARGABIj+3PgDXjTG2PgJwBzdYgIjAAkQEFiAisDtg18qtzM6+eci1E74o8P24wQJE BBYgIrAAETvYDdi3wmtwg30gYeVRzNo+uME+mMGH1+EGCxAR2Adwa2UrZm9bVgSRZbDnef7rM2xh jGEGNyCwIUMNr82KYGWXorp8Flse5dqs+Uv/sdxgV3K+Erg0wCLLo300h2axJ7ArE1JgIbArElXg nMCuQFh5Vma3JbB3shLg2ZndjsDe4VJcl/deYc+uvenCugT2Rm6ufDdmeX0Ce4PlFRe3Vb4TgV2f wH7SEtUxxnQ6nbY+DmTOZ537COwXiCuvQlzXIbCfJK68GpG9n8B+QFh5ZafTSWjvILBXnO+hjsej yPKSzr8HQvt1AvsPogr/8124jcBesQyUwQKrslsJ7AXLj0LH43Hjk8C+/Pr1a+sjPJV5WKwAJPyP BgARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAAR gQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWI CCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxA RGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGAB IgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgILEBFYgIjAAkQEFiAisAARgQWICCxARGABIgIL EBFYgIjAAkQEFiAisAARgQWICCxARGABIv8BwkiQRRfQm6sAAAAASUVORK5CYII= "
id="image390"
x="1754.3503"
y="-112.64524"
clip-path="url(#clipPath3044)"
transform="translate(199.80084,-97.358435)" /><text
transform="translate(12.540657,-95.216843)" /><text
xml:space="preserve"
style="font-weight:bold;font-size:4.93889px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:end;text-anchor:end;fill:#e4e4e4;fill-opacity:1;stroke:none;stroke-width:0.396875;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
x="1861.4604"
y="-133.17824"
id="text8997-8"
clip-path="url(#clipPath16400)"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.93889px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="1861.4604"
y="-133.17824"
id="tspan9051-4">spread_radius: 10.0</tspan><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.93889px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="1861.4604"
y="-126.82025"
id="tspan12511-9" /></text><text
xml:space="preserve"
style="font-weight:bold;font-size:4.93889px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:end;text-anchor:end;fill:#e4e4e4;fill-opacity:1;stroke:none;stroke-width:0.396875;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
style="font-weight:bold;font-size:4.58611px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:end;text-anchor:end;fill:#e4e4e4;fill-opacity:1;stroke:none;stroke-width:0.396875;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
x="1946.3485"
y="-133.17824"
id="text8997-9-2"
clip-path="url(#clipPath16314)"><tspan
clip-path="url(#clipPath16314)"
transform="translate(7.6183866)"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.93889px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.58611px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="1946.3485"
y="-133.17824"
id="tspan9051-0-1">spread_radius: 0.0</tspan><tspan
id="tspan9051-0-1">spread_radius: [0.0, 0.0]</tspan><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.93889px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.58611px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="1946.3485"
y="-126.82025"
y="-127.2744"
id="tspan12511-7-0" /></text><text
xml:space="preserve"
style="font-weight:bold;font-size:4.93889px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:end;text-anchor:end;fill:#e4e4e4;fill-opacity:1;stroke:none;stroke-width:0.396875;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
style="font-weight:bold;font-size:4.58611px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:end;text-anchor:end;fill:#e4e4e4;fill-opacity:1;stroke:none;stroke-width:0.396875;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
x="2028.9165"
y="-133.17824"
id="text8997-1-5"
clip-path="url(#clipPath16310)"><tspan
clip-path="url(#clipPath16310)"
transform="translate(6.91627)"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.93889px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.58611px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="2028.9165"
y="-133.17824"
id="tspan9051-6-0">spread_radius: -10.0</tspan><tspan
id="tspan9051-6-0">spread_radius: [10.0, -25]</tspan><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.93889px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.58611px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="2028.9165"
y="-126.82025"
y="-127.2744"
id="tspan12511-0-6" /></text><rect
style="fill:none;stroke-width:0.26458332;paint-order:fill markers stroke;fill-opacity:1;stroke:#ff0000;stroke-opacity:1;stroke-dasharray:1.58749992,1.58749992;stroke-dashoffset:0"
id="rect394"
@ -309,15 +303,32 @@
height="34.395832"
x="1808.9017"
y="-188.4716" /><rect
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:0.264583;stroke-dasharray:1.5875, 1.5875;stroke-dashoffset:0;stroke-opacity:1;paint-order:fill markers stroke"
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:0.264582;stroke-dasharray:1.5875, 1.5875;stroke-dashoffset:0;stroke-opacity:1;paint-order:fill markers stroke"
id="rect4506"
width="58.208332"
height="44.979164"
x="1969.7845"
y="-194.13376" /><rect
width="47.625"
height="52.916664"
x="1975.0762"
y="-198.10251" /><rect
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:0.264583;stroke-dasharray:1.5875, 1.5875;stroke-dashoffset:0;stroke-opacity:1;paint-order:fill markers stroke"
id="rect4508"
width="53.710411"
height="40.481251"
x="1891.5787"
y="-190.98524" /></g><inkscape:templateinfo><inkscape:name>Padrão</inkscape:name><inkscape:date>2022-06-22</inkscape:date></inkscape:templateinfo></svg>
y="-190.98524" /><text
xml:space="preserve"
style="font-weight:bold;font-size:4.58611px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:end;text-anchor:end;fill:#e4e4e4;fill-opacity:1;stroke:none;stroke-width:0.396875;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1"
x="1946.3485"
y="-133.17824"
id="text798"
clip-path="url(#clipPath16314)"
transform="translate(-75.279094)"><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.58611px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="1946.3485"
y="-133.17824"
id="tspan794">spread_radius: [10.0, 10.0]</tspan><tspan
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:4.58611px;font-family:'Fira Code';-inkscape-font-specification:'Fira Code Bold';fill:#1a1a1a;stroke-width:0.396875"
x="1946.3485"
y="-127.2744"
id="tspan796" /></text></g><inkscape:templateinfo><inkscape:name>Padrão</inkscape:name><inkscape:date>2022-06-22</inkscape:date></inkscape:templateinfo></svg>

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -6,12 +6,12 @@ from kivy.graphics.vertex_instructions cimport VertexInstruction
cdef class BoxShadow(Fbo):
cdef bint _inset
cdef float _blur_radius
cdef tuple _pos
cdef tuple _size
cdef tuple _offset
cdef tuple _border_radius
cdef float _blur_radius
cdef float _spread_radius
cdef tuple _spread_radius
cdef VertexInstruction _fbo_rect
cdef VertexInstruction _texture_container
cdef Scale _fbo_scale

View File

@ -49,7 +49,7 @@ Example:
pos: self.pos
size: self.size
offset: 0, -10
spread_radius: -20
spread_radius: -20, -20
border_radius: 10, 10, 10, 10
blur_radius: 80 if self.state == "normal" else 50
@ -78,7 +78,7 @@ uniform sampler2D texture0;
uniform int inset;
uniform float blur_radius;
uniform vec4 border_radius;
uniform float spread_radius;
uniform vec2 spread_radius;
uniform vec2 size;
uniform vec2 offset;
@ -159,7 +159,7 @@ cdef class BoxShadow(Fbo):
The negative ones indicate that the shadow should move to the left and/or down.
`blur_radius`: float, defaults to ``15.0``.
Define the shadow blur radius. Controls shadow expansion and softness.
`spread_radius`: float, defaults to ``0.0``.
`spread_radius`: list | tuple, defaults to ``(0.0, 0.0)``.
Define the shrink/expansion of the shadow.
`border_radius`: list | tuple, defaults to ``(0.0, 0.0, 0.0, 0.0)``.
Specifies the radii used for the rounded corners clockwise:
@ -173,7 +173,7 @@ cdef class BoxShadow(Fbo):
size = kwargs.get("size", (100.0, 100.0))
offset = kwargs.get("offset", (0.0, 0.0))
blur_radius = kwargs.get("blur_radius", 15.0)
spread_radius = kwargs.get("spread_radius", 0.0)
spread_radius = kwargs.get("spread_radius", (0.0, 0.0))
border_radius = kwargs.get("border_radius", (0.0, 0.0, 0.0, 0.0))
self._inset = self._check_bool(inset)
@ -187,7 +187,7 @@ cdef class BoxShadow(Fbo):
self._check_float("blur_radius", blur_radius),
min_value=0.0
)
self._spread_radius = self._check_float("spread_radius", spread_radius)
self._spread_radius = self._check_iter("spread_radius", spread_radius)
self._border_radius = self._bounded_value(
self._check_iter("border_radius", border_radius, components=4),
min_value=1.0,
@ -249,8 +249,8 @@ cdef class BoxShadow(Fbo):
# The position should be adjusted according to the size expansion,
# with half the size used in the _adjusted_size method
if not self.inset:
x -= self.blur_radius * 1.5 + self.spread_radius - self.offset[0]
y -= self.blur_radius * 1.5 + self.spread_radius - self.offset[1]
x -= self.blur_radius * 1.5 + self.spread_radius[0] - self.offset[0]
y -= self.blur_radius * 1.5 + self.spread_radius[1] - self.offset[1]
return (x, y)
@ -264,8 +264,8 @@ cdef class BoxShadow(Fbo):
# size expansion
if not self.inset and w > 0.0 and h > 0.0:
w += self.blur_radius * 3 + self.spread_radius * 2
h += self.blur_radius * 3 + self.spread_radius * 2
w += self.blur_radius * 3 + self.spread_radius[0] * 2
h += self.blur_radius * 3 + self.spread_radius[1] * 2
w = max(0.0, w)
h = max(0.0, h)
@ -408,20 +408,20 @@ cdef class BoxShadow(Fbo):
@property
def spread_radius(self):
'''Define the shrink/expansion of the shadow.
'''Define the shrink/expansion of the shadow in `[horizontal, vertical]` format.
Defaults to ``0.0``.
Defaults to ``(0.0, 0.0)``.
This property is especially useful for cases where you want to achieve
a softer shadow around the element, by setting a negative value for
a softer shadow around the element, by setting negative values for
:attr:`spread_radius` and a larger value for :attr:`blur_radius` as
in the :ref:`example <example>`.
- :attr:`inset` **OFF**:
In the image below, the target element has a raw size of ``200 x 150px``.
Positive changes to the :attr:`spread_radius` value will cause the raw
:attr:`size` of the shadow to increase in both horizontal and vertical
directions, while negative values will cause the shadow to shrink.
Positive changes to the :attr:`spread_radius` values will cause the raw
:attr:`size` of the shadow to increase, while negative values will cause
the shadow to shrink.
.. image:: images/boxshadow_spread_radius.svg
:align: center
@ -440,7 +440,7 @@ cdef class BoxShadow(Fbo):
@spread_radius.setter
def spread_radius(self, value):
self._spread_radius = self._check_float("spread_radius", value)
self._spread_radius = self._check_iter("spread_radius", value)
self._update_shadow()
@property
@ -559,7 +559,7 @@ cdef class BoxShadow(Fbo):
size: self.size
offset: 0, -10
blur_radius: 25
spread_radius: -10
spread_radius: -10, -10
border_radius: 10, 10, 10, 10
canvas:
@ -606,7 +606,7 @@ cdef class BoxShadow(Fbo):
size: self.size
offset: 0, -10
blur_radius: 25
spread_radius: -10
spread_radius: -10, -10
border_radius: 10, 10, 10, 10
|

View File

@ -28,7 +28,7 @@ class BoxShadowTest(GraphicUnitTest):
pos=(50, 50),
size=(150, 150),
offset=(0, 10),
spread_radius=10,
spread_radius=(10, -10),
border_radius=(10, 10, 10, 10),
blur_radius=80,
)
@ -42,7 +42,7 @@ class BoxShadowTest(GraphicUnitTest):
pos=(50, 50),
size=(150, 150),
offset=(0, 10),
spread_radius=10,
spread_radius=(10, -10),
border_radius=(10, 10, 10, 10),
blur_radius=80,
)
@ -57,7 +57,7 @@ class BoxShadowTest(GraphicUnitTest):
bs.pos = [50, 50]
bs.size = [150, 150]
bs.offset = [0, 10]
bs.spread_radius = 10
bs.spread_radius = [10, -10]
bs.border_radius = [10, 10, 10, 10]
bs.blur_radius = 40
r(wid)
@ -71,7 +71,7 @@ class BoxShadowTest(GraphicUnitTest):
bs.pos = 50, 50
bs.size = raw_size
bs.blur_radius = 80
bs.spread_radius = 10
bs.spread_radius = -10, 10
# The size of the rectangle containing the FBO texture (shadow) needs
# to be adjusted according to the size of the shadow, otherwise there
@ -79,11 +79,11 @@ class BoxShadowTest(GraphicUnitTest):
adjusted_size = (
max(
0,
raw_size[0] + bs.blur_radius * 3 + bs.spread_radius * 2,
raw_size[0] + bs.blur_radius * 3 + bs.spread_radius[0] * 2,
),
max(
0,
raw_size[1] + bs.blur_radius * 3 + bs.spread_radius * 2,
raw_size[1] + bs.blur_radius * 3 + bs.spread_radius[1] * 2,
),
)
@ -104,16 +104,16 @@ class BoxShadowTest(GraphicUnitTest):
pos=(50, 50),
size=raw_size,
blur_radius=80,
spread_radius=10
spread_radius=(10, -10)
)
adjusted_size = (
max(
0,
raw_size[0] + bs.blur_radius * 3 + bs.spread_radius * 2,
raw_size[0] + bs.blur_radius * 3 + bs.spread_radius[0] * 2,
),
max(
0,
raw_size[1] + bs.blur_radius * 3 + bs.spread_radius * 2,
raw_size[1] + bs.blur_radius * 3 + bs.spread_radius[1] * 2,
),
)
@ -140,18 +140,18 @@ class BoxShadowTest(GraphicUnitTest):
bs.size = raw_size
bs.offset = offset
bs.blur_radius = 80
bs.spread_radius = 10
bs.spread_radius = -10, 10
# If the size of the rectangle containing the FBO texture (shadow)
# changes, its position will need to be adjusted.
adjusted_pos = (
raw_pos[0]
- bs.blur_radius * 1.5
- bs.spread_radius
- bs.spread_radius[0]
+ bs.offset[0],
raw_pos[0]
- bs.blur_radius * 1.5
- bs.spread_radius
- bs.spread_radius[1]
+ bs.offset[1],
)
@ -173,16 +173,16 @@ class BoxShadowTest(GraphicUnitTest):
size=raw_size,
offset=offset,
blur_radius=80,
spread_radius=10
spread_radius=(10, -10)
)
adjusted_pos = (
raw_pos[0]
- bs.blur_radius * 1.5
- bs.spread_radius
- bs.spread_radius[0]
+ bs.offset[0],
raw_pos[0]
- bs.blur_radius * 1.5
- bs.spread_radius
- bs.spread_radius[1]
+ bs.offset[1],
)
@ -205,7 +205,7 @@ class BoxShadowTest(GraphicUnitTest):
bs.size = 150, 150
bs.offset = 10, -100
bs.blur_radius = -80
bs.spread_radius = -200
bs.spread_radius = -200, -100
bs.border_radius = 0, 0, 100, 0
assert bs.size == (0, 0)
@ -226,7 +226,7 @@ class BoxShadowTest(GraphicUnitTest):
size=(150, 150),
offset=(10, -100),
blur_radius=-80,
spread_radius=-200,
spread_radius=(-200, -100),
border_radius=(0, 0, 100, 0),
)