Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a6c010

Browse files
committed
feat(cava): add min_bar_height option for customizable bar height limits
1 parent010eb94 commit3a6c010

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

‎docs/widgets/(Widget)-Cava.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
| Option| Type| Default| Description|
66
|--------|------|---------|-------------|
77
|`bar_height`| integer| 20| The height of bars in pixels|
8+
|`min_bar_height`| integer| 0| The minimum height of bars in pixels|
89
|`bars_number`| integer| 10| The number of bars (0-512). 0 sets it to auto|
910
|`output_bit_format`| string| "16bit"| Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530)|
1011
|`bar_spacing`| integer| 1| Space between bars|
@@ -33,6 +34,7 @@
3334
type:"yasb.cava.CavaWidget"
3435
options:
3536
bar_height:12
37+
min_bar_height:0
3638
gradient:1
3739
reverse:0
3840
foreground:"#89b4fa"
@@ -54,6 +56,7 @@
5456
## Description of Options
5557
5658
- **bar_height**: The height of bars in pixels.
59+
- **min_bar_height**: The minimum height of bars in pixels.
5760
- **bars_number**: The number of bars to display. Can be between 0 and 512. 0 sets it to auto.
5861
- **output_bit_format**: Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530).
5962
- **bar_spacing**: Space between bars in number of characters.

‎src/core/validation/widgets/yasb/cava.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
DEFAULTS= {
22
'bar_height':20,
3+
'min_bar_height':0,
34
'bars_number':10,
45
'output_bit_format':"16bit",
56
'bar_spacing':1,
67
'bar_width':3,
8+
'min_bar_height':1,
79
'sleep_timer':0,
810
'sensitivity':100,
911
'lower_cutoff_freq':50,
@@ -28,6 +30,11 @@
2830
'required':False,
2931
'default':DEFAULTS['bar_height']
3032
},
33+
'min_bar_height': {
34+
'type':'integer',
35+
'required':False,
36+
'default':DEFAULTS['min_bar_height']
37+
},
3138
'bars_number': {
3239
'type':'integer',
3340
'required':False,

‎src/core/widgets/yasb/cava.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ def paintEvent(self, event):
2626
left_margin=self._cava_widget._bar_spacing//2
2727
fori,sampleinenumerate(self._cava_widget.samples):
2828
x=left_margin+i* (self._cava_widget._bar_width+self._cava_widget._bar_spacing)
29-
height=int(sample*self._cava_widget._height)
29+
# Compute height and enforce minimum height of self._cava_widget._min_height
30+
computed_height=int(sample*self._cava_widget._height)
31+
height=max(self._cava_widget._min_height,computed_height)
3032
y=self._cava_widget._height-height
3133
ifheight>0:
34+
print(height)
3235
ifself._cava_widget._gradient==1andself._cava_widget.colors:
3336
gradient=QLinearGradient(0,1,0,0)
3437
gradient.setCoordinateMode(QLinearGradient.CoordinateMode.ObjectBoundingMode)
@@ -46,6 +49,7 @@ class CavaWidget(BaseWidget):
4649
def__init__(
4750
self,
4851
bar_height:int,
52+
min_bar_height:int,
4953
bars_number:int,
5054
output_bit_format:str,
5155
bar_spacing:int,
@@ -70,6 +74,7 @@ def __init__(
7074
super().__init__(class_name="cava-widget")
7175
# Widget configuration
7276
self._height=bar_height
77+
self._min_height=min_bar_height
7378
self._bars_number=bars_number
7479
self._output_bit_format=output_bit_format
7580
self._bar_spacing=bar_spacing

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp