From afe834cdb0df207dba4f4ea3fe9e4f5c03a63dde Mon Sep 17 00:00:00 2001 From: mashiros <490328928@qq.com> Date: Tue, 23 Jul 2024 22:43:12 +0800 Subject: [PATCH] =?UTF-8?q?V1.5.0=20-=20=E6=A0=B7=E5=BC=8F[=E7=BA=BF]?= =?UTF-8?q?=E6=96=B0=E5=A2=9E:=E5=9C=86=E8=A7=92=E7=BA=BF=E5=B8=BD?= =?UTF-8?q?=E9=80=89=E9=A1=B9=20-=20=E6=A0=B7=E5=BC=8F[=E5=9C=86]=E6=96=B0?= =?UTF-8?q?=E5=A2=9E:=E5=9C=86=E8=A7=92=E7=BA=BF=E5=B8=BD=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E4=B8=8E=E9=95=9C=E5=83=8F=E9=A2=91=E8=B0=B1=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locales/ja.qm | Bin 7867 -> 8173 bytes Locales/zh.qm | Bin 7355 -> 7655 bytes Locales/zh_TW.qm | Bin 7355 -> 7655 bytes Presets/Circle/settings.xml | 2 +- Presets/Line/settings.xml | 2 +- package.json | 2 +- styles/Preset_circle/Style.qml | 56 ++++++++++++++--- styles/Preset_line/Style.qml | 135 ++++++++++++++++++++++++++++++++--------- 8 files changed, 156 insertions(+), 41 deletions(-) diff --git a/Locales/ja.qm b/Locales/ja.qm index fd5d78600dc37c0ec83f472978bbe59b3aaa5895..d1ea8e5a0dd657a0b5cf698d7806bbaa1000e0ab 100644 GIT binary patch delta 856 zcmZ8fX-HII6g~6wy*Ji#-Z(RknKh#k*`__r2#P4pa7oFK#*7xGlpLByoyI~ZhsXGB8h@$5oGzt+9Hp?JEH_E4Z$s z-vQk+?qN(gp!DYY`(Bg4GVY_9R0mw*h6|<=p-O(CFogN(`E|}woyC07hwH>Mo!^8GVqvkufTM$$ObuvG0ViVj|G& z64or$kf1ohEPo-QSYdnrdOB|w4i8-n76B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nw?mZZ7)@>l?BSB_wlc4qRRD7 zg1FUev1D0viP@$!tHpM}ZdaxAdM; amMwG7{}j`GL#mU)9n7&AEhb6uzwsBLJLl#A delta 574 zcmXAlT}YF06vm(TKi~J=^lg9L<~E_W71|`&4#P1( z9s+E`F}Jg}A98RzP_i0wb1%urM^9 zbOMDfXuV0k;W^r(dZ2VJHsF>jV$;s$wd_)L8ZfJDa>PO!VN-!|K!Wb*jz6^FyRb>_ zbq?8JJx6nc^4gkqfam2suMPtCO44T1kQ|v$00_&c^>>KtqG*zAWnTF<8zFaIewp1y zuIInnJ4Cl+^;ymJ>ZfED&{Fz>Yx@A> z0sV%t8oHO^Xit0d^q2`P7mU-Z^Uc+5ZgCPw`WoG{=4X?EMt^A%11?PepBqfiia@ Yty{sxQuFIXxy2(TI!Z&T@GtB62fKNqZ~y=R diff --git a/Presets/Circle/settings.xml b/Presets/Circle/settings.xml index c4a591e..f2148c7 100644 --- a/Presets/Circle/settings.xml +++ b/Presets/Circle/settings.xml @@ -1,5 +1,5 @@ "nvg://advp.widget.mashiros.top/advp-style-preset/circle" - {"Gradient Style":0,"Radial Gradient Settings":{"Inside Position Color":"#f44336","Middle Position Color":"#4caf50","Outside Position Color":"#03a9f4","Inside Position":40,"Middle Position":60,"Outside Position":80},"Conical Gradient Settings":{"Start Position Color":"#f44336","Quarter Position Color":"#4caf50","Middle Position Color":"#03a9f4","End Position Color":"#ffeb3b"},"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":80,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Rotation Direction":0,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} + {"Gradient Style":0,"Radial Gradient Settings":{"Inside Position Color":"#f44336","Middle Position Color":"#4caf50","Outside Position Color":"#03a9f4","Inside Position":40,"Middle Position":60,"Outside Position":80},"Conical Gradient Settings":{"Start Position Color":"#f44336","Quarter Position Color":"#4caf50","Middle Position Color":"#03a9f4","End Position Color":"#ffeb3b"},"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":80,"Data Length":0,"Line Cap":0,"Channel":2,"Reverse":false,"Mirror":false,"Rotate":false,"Rotation Direction":0,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} \ No newline at end of file diff --git a/Presets/Line/settings.xml b/Presets/Line/settings.xml index a7efee6..c78de8a 100644 --- a/Presets/Line/settings.xml +++ b/Presets/Line/settings.xml @@ -1,5 +1,5 @@ - {"Gradient Style":0,"Linear Gradient Settings":{"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4"},"Radial Gradient Settings":{"Inside Position Color":"#f44336","Middle Position Color":"#4caf50","Outside Position Color":"#03a9f4","Inside Position":0,"Middle Position":50,"Outside Position":100,"Center X Offset":0,"Center Y Offset":0},"Center Line":true,"Center Color":"#ff4500","Center Width":20,"Direction":0,"Line Color":"#ff4500","Line Position":0,"Data Length":0,"Channel":2,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10,"X Scale":100,"Y Scale":100,"X Offset":0,"Y Offset":0},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} + {"Gradient Style":0,"Linear Gradient Settings":{"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4"},"Radial Gradient Settings":{"Inside Position Color":"#f44336","Middle Position Color":"#4caf50","Outside Position Color":"#03a9f4","Inside Position":0,"Middle Position":50,"Outside Position":100,"Center X Offset":0,"Center Y Offset":0},"Center Line":true,"Center Color":"#ff4500","Center Width":20,"Line Color":"#ff4500","Line Position":0,"Data Length":0,"Channel":2,"Direction":0,"Line Cap":0,"Initial Point Size":0,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10,"X Scale":100,"Y Scale":100,"X Offset":0,"Y Offset":0},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}} "nvg://advp.widget.mashiros.top/advp-style-preset/line" \ No newline at end of file diff --git a/package.json b/package.json index 462844a..f16ab71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "top.mashiros.widget.advp", - "version": "1.4.4", + "version": "1.5.0", "title": { "en": "ADV Plugin", diff --git a/styles/Preset_circle/Style.qml b/styles/Preset_circle/Style.qml index 0703fe2..a8e4e4e 100644 --- a/styles/Preset_circle/Style.qml +++ b/styles/Preset_circle/Style.qml @@ -90,6 +90,9 @@ AdvpStyleTemplate { readonly property real halfHeight: height/2 readonly property real halfMinLength: minLength/2 + readonly property int linecap: configs["Line Cap"] + readonly property bool mirror: configs["Mirror"] + onConfigsUpdated: { gradientStyle = configs["Gradient Style"]; @@ -117,16 +120,32 @@ AdvpStyleTemplate { let deg, deltaR, r1, r2, _rhmLen; _rhmLen = mainRatio*halfMinLength; - for (let j=0; j < channel; j++) { - for (let i=0; i < dataLength; i++) { - deg = degUnit*((i+j*dataLength)*dotGap+offsetAngle*(1-2*rotationDirection)); - deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio; - r1 = _rhmLen+1+deltaR*(linePosition!==2); - r2 = _rhmLen-1-deltaR*(linePosition!==1); - outerPos.push([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]); - innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]); + if (mirror) { + for (let j=0; j < channel; j++) { + for (let i=0; i < dataLength; i++) { + deg = degUnit*((i+j*dataLength)*dotGap+offsetAngle*(1-2*rotationDirection)); + deltaR = audioData[reverse*(dataLength+((2*i+1)*j-i-1))+(!reverse)*((2*dataLength-2*i-1)*j+i)] * ratio; + // deltaR = audioData[reverse*(dataLength-(i+1)*(j===0)+i*(j===1))+(!reverse)*(i*(j===0)+(dataLength*2-i-1)*(j===1))] * ratio; + r1 = _rhmLen+1+deltaR*(linePosition!==2); + r2 = _rhmLen-1-deltaR*(linePosition!==1); + outerPos.push([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]); + innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]); + } + } + } else { + for (let j=0; j < channel; j++) { + for (let i=0; i < dataLength; i++) { + deg = degUnit*((i+j*dataLength)*dotGap+offsetAngle*(1-2*rotationDirection)); + deltaR = audioData[reverse*(dataLength*(j+1)-i-1)+(!reverse)*(i+j*dataLength)] * ratio; + r1 = _rhmLen+1+deltaR*(linePosition!==2); + r2 = _rhmLen-1-deltaR*(linePosition!==1); + outerPos.push([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]); + innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]); + } } } + + conicalGradient.angle = offsetAngle*(2*rotationDirection-1); offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; } @@ -152,7 +171,7 @@ AdvpStyleTemplate { audioData[i] /= (uDataLen * normalizing_ratio); } } - + context.lineCap=["butt", "round", "square"][linecap]; context.clearRect(0, 0, width+32, height+32); createPoint(); @@ -179,7 +198,7 @@ AdvpStyleTemplate { } defaultValues: { - "Version": "1.2.2", + "Version": "1.3.0", "Gradient Style": 0, "Radial Gradient Settings": { "Inside Position Color": "#f44336", @@ -200,8 +219,10 @@ AdvpStyleTemplate { "Line Width": 1, "Max Range": 80, "Data Length": 0, + "Line Cap": 0, "Channel": 2, "Reverse": false, + "Mirror": false, "Rotate": false, "Rotation Direction": 0, "Ratate Speed": 10, @@ -354,9 +375,17 @@ AdvpStyleTemplate { model: [64, 32, 16, 8] } + P.SelectPreference { + name: "Line Cap" + label: qsTr("Line Cap") + defaultValue: defaultValues["Line Cap"] + model: [qsTr("butt"), qsTr("round"), qsTr("square")] + } + P.Separator {} P.SpinPreference { + id: _cfg_channel name: "Channel" label: qsTr("Channel") message: "1 to 2" @@ -368,6 +397,13 @@ AdvpStyleTemplate { } P.SwitchPreference { + name: "Mirror" + label: qsTr("Mirror Spectrum") + defaultValue: defaultValues["Mirror"] + visible: _cfg_channel.value > 1 + } + + P.SwitchPreference { name: "Reverse" label: qsTr("Reverse Spectrum") defaultValue: defaultValues["Reverse"] diff --git a/styles/Preset_line/Style.qml b/styles/Preset_line/Style.qml index 179059b..b2d367e 100644 --- a/styles/Preset_line/Style.qml +++ b/styles/Preset_line/Style.qml @@ -56,6 +56,19 @@ AdvpStyleTemplate { property real radialGradient_xOffset property real radialGradient_yOffset + property bool centerRotateFlag + property bool lineRotateFlag + property real centerRotateAngleTangent + property real lineRotateAngleTangent + property real xOffset + property real yOffset + property real xScale + property real yScale + + property real halfHeight + property real _dx + property real minv_ratio + Canvas { id: centerLine anchors.fill: parent @@ -67,18 +80,28 @@ AdvpStyleTemplate { context.clearRect(0, 0, width+32, height+32); context.fillStyle = center_color; if (vertical_flag) { - if (linePosition) { + if(lineRotateFlag || centerRotateFlag) { + context.transform(yScale, lineRotateAngleTangent, -centerRotateAngleTangent, xScale, 2*_y_dy+yOffset*height, xOffset*width-lineRotateAngleTangent*(halfHeight-_y_dy)); + context.fillRect(halfHeight-_y_dy-center_width/2, 0, center_width, height); + context.resetTransform(); + } + else if (linePosition) { let _y = width/2 + width/2*(3-2*linePosition)*Boolean(linePosition); context.fillRect(_y+(linePosition-2)*center_width, 0, center_width, height); } else { - context.fillRect(width/2-_y_dy-center_width/2, 0, center_width, width); + context.fillRect(halfHeight-_y_dy-center_width/2, 0, center_width, height); } } else { - if (linePosition) { + if(lineRotateFlag || centerRotateFlag) { + context.transform(xScale, centerRotateAngleTangent, -lineRotateAngleTangent, yScale, xOffset*width+lineRotateAngleTangent*(halfHeight-_y_dy), yOffset*height); + context.fillRect(0, halfHeight-_y_dy-center_width/2, width, center_width); + context.resetTransform(); + } + else if (linePosition) { let _y = height/2 + height/2*(3-2*linePosition)*Boolean(linePosition); context.fillRect(0, _y+(linePosition-2)*center_width, width, center_width); } else { - context.fillRect(0, height/2-_y_dy-center_width/2, width, center_width); + context.fillRect(0, halfHeight-_y_dy-center_width/2, width, center_width); } } } @@ -93,33 +116,43 @@ AdvpStyleTemplate { readonly property int uDataLen: Math.pow(2, configs["Data Length"]); readonly property int dataLength: 64/uDataLen readonly property int channel: configs["Channel"] - readonly property bool centerRotateFlag: configs["Rotate Settings"]["Center Enable"] - readonly property real centerRotateAngleTangent: centerRotateFlag*Math.tan(configs["Rotate Settings"]["Center Angle"]*Math.PI/180) - readonly property bool lineRotateFlag: configs["Rotate Settings"]["Line Enable"] - readonly property real lineRotateAngleTangent: lineRotateFlag*Math.tan(configs["Rotate Settings"]["Line Angle"]*Math.PI/180) + readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] readonly property real amplitude: 400.0/configs["Data Settings"]["Amplitude"] readonly property int unitStyle: configs["Data Settings"]["Unit Style"] - readonly property real xOffset: configs["Rotate Settings"]["X Offset"]/100 - readonly property real yOffset: configs["Rotate Settings"]["Y Offset"]/100 - readonly property real xScale: configs["Rotate Settings"]["X Scale"]/100 - readonly property real yScale: configs["Rotate Settings"]["Y Scale"]/100 - readonly property real halfWidth: vertical_flag ? height/2 : width/2 - readonly property real halfHeight: vertical_flag ? width/2 : height/2 readonly property int l_start: (channel===1)*dataLength readonly property int r_stop: dataLength+dataLength*(channel!==0) readonly property int total: r_stop-l_start readonly property real _ux: halfWidth*2/(r_stop-l_start) - readonly property real _dx: Math.round(_ux/2) + + readonly property int linecap: configs["Line Cap"] + + function roundRect(context, x, y, w, h, r, lc) { + context.beginPath(); + context.lineCap=lc; + context.lineWidth=r; + context.moveTo(x, y); + context.lineTo(x+w, y+h); + context.stroke(); + context.closePath(); + } + + on_UxChanged: { + _dx = _ux/2; + } onWidthChanged: { if (gradientStyle === 1) { linearGradient.x2 = width*(configs["Linear Gradient Settings"]["Gradient Direction"]!==1); linearGradient.y2 = height*(configs["Linear Gradient Settings"]["Gradient Direction"]%2); } + + halfHeight = vertical_flag ? width/2 : height/2; + _dx = _ux/2; + centerLine.requestPaint(); } @@ -130,6 +163,10 @@ AdvpStyleTemplate { linearGradient.x2 = width*(configs["Linear Gradient Settings"]["Gradient Direction"]!==1); linearGradient.y2 = height*(configs["Linear Gradient Settings"]["Gradient Direction"]%2); } + + halfHeight = vertical_flag ? width/2 : height/2; + _dx = _ux/2; + centerLine.requestPaint(); } @@ -162,6 +199,21 @@ AdvpStyleTemplate { radialGradient_xOffset = configs["Radial Gradient Settings"]["Center X Offset"]; radialGradient_yOffset = configs["Radial Gradient Settings"]["Center Y Offset"]; } + + centerRotateFlag = configs["Rotate Settings"]["Center Enable"]; + lineRotateFlag = configs["Rotate Settings"]["Line Enable"]; + centerRotateAngleTangent = centerRotateFlag*Math.tan(configs["Rotate Settings"]["Center Angle"]*Math.PI/180); + lineRotateAngleTangent = lineRotateFlag*Math.tan(configs["Rotate Settings"]["Line Angle"]*Math.PI/180); + xOffset = configs["Rotate Settings"]["X Offset"]/100; + yOffset = configs["Rotate Settings"]["Y Offset"]/100; + xScale = configs["Rotate Settings"]["X Scale"]/100; + yScale = configs["Rotate Settings"]["Y Scale"]/100; + + minv_ratio = configs["Initial Point Size"]/100; + + halfHeight = vertical_flag ? width/2 : height/2; + _dx = _ux/2; + centerLine.requestPaint(); } @@ -205,14 +257,16 @@ AdvpStyleTemplate { let _y; let _dy; + let lc = ["butt", "round", "square"][linecap]; if (vertical_flag) { if(lineRotateFlag || centerRotateFlag) { context.transform(yScale, lineRotateAngleTangent, -centerRotateAngleTangent, xScale, 2*_y_dy+yOffset*height, xOffset*width-lineRotateAngleTangent*(halfHeight-_y_dy)); - context.fillStyle = line_color; + context.strokeStyle = line_color; for (let i=l_start; i