Browse Source

V1.5.0

- 样式[线]新增:圆角线帽选项
- 样式[圆]新增:圆角线帽选项与镜像频谱选项
master
mashiros 7 months ago
parent
commit
afe834cdb0
  1. BIN
      Locales/ja.qm
  2. BIN
      Locales/zh.qm
  3. BIN
      Locales/zh_TW.qm
  4. 2
      Presets/Circle/settings.xml
  5. 2
      Presets/Line/settings.xml
  6. 2
      package.json
  7. 56
      styles/Preset_circle/Style.qml
  8. 135
      styles/Preset_line/Style.qml

BIN
Locales/ja.qm

Binary file not shown.

BIN
Locales/zh.qm

Binary file not shown.

BIN
Locales/zh_TW.qm

Binary file not shown.

2
Presets/Circle/settings.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map>
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/circle"</value>
<value name="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}}</value>
<value name="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,"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}}</value>
</map>

2
Presets/Line/settings.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map>
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/line">{"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}}</value>
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/line">{"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}}</value>
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/line"</value>
</map>

2
package.json

@ -1,6 +1,6 @@
{
"name": "top.mashiros.widget.advp",
"version": "1.4.4",
"version": "1.5.0",
"title": {
"en": "ADV Plugin",

56
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"]

135
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<r_stop; i++) {
_y = halfHeight*(1-(linePosition!==2)*audioData[i])-_y_dy;
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[i];
context.fillRect(_y, _ux * (i-l_start), _dy, _dx);
roundRect(context, _y-_dx*minv_ratio/2, _dx+_ux * (i-l_start), _dx*minv_ratio, 0, _dx, lc);
roundRect(context, _y+_dx*minv_ratio/2, _dx+_ux * (i-l_start), _dy, 0, _dx, lc);
}
if (centerLineFlag) {
context.fillRect(halfHeight-_y_dy-center_width/2, 0, center_width, height);
@ -221,20 +275,22 @@ AdvpStyleTemplate {
} else if (linePosition) {
let _flag = 1-2*(linePosition===1);
_y = halfHeight + halfHeight*(3-2*linePosition)*Boolean(linePosition);
context.fillStyle = line_color;
context.strokeStyle = line_color;
for (let i=l_start; i<r_stop; i++) {
_dy = width*audioData[i]*_flag;
context.fillRect(_y, _ux * (i-l_start), _dy, _dx);
roundRect(context, _y-_dx*minv_ratio/2, _dx+_ux * (i-l_start), _dx*minv_ratio, 0, _dx, lc);
roundRect(context, _y+_dx*minv_ratio/2, _dx+_ux * (i-l_start), _dy, 0, _dx, lc);
}
if (centerLineFlag) {
context.fillRect(_y+(linePosition-2)*center_width, 0, center_width, height);
}
} else {
context.fillStyle = line_color;
context.strokeStyle = line_color;
for (let i=l_start; i<r_stop; i++) {
_y = halfHeight*(1-(linePosition!==2)*audioData[i])-_y_dy;
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[i];
context.fillRect(_y, _ux * (i-l_start), _dy, _dx);
roundRect(context, _y-_dx*minv_ratio/2, _dx+_ux * (i-l_start), _dx*minv_ratio, 0, _dx, lc);
roundRect(context, _y+_dx*minv_ratio/2, _dx+_ux * (i-l_start), _dy, 0, _dx, lc);
}
if (centerLineFlag) {
context.fillRect(halfHeight-_y_dy-center_width/2, 0, center_width, height);
@ -244,11 +300,12 @@ AdvpStyleTemplate {
//
if(lineRotateFlag || centerRotateFlag) {
context.transform(xScale, centerRotateAngleTangent, -lineRotateAngleTangent, yScale, xOffset*width+lineRotateAngleTangent*(halfHeight-_y_dy), yOffset*height);
context.fillStyle = line_color;
context.strokeStyle = line_color;
for (let i=l_start; i<r_stop; i++) {
_y = halfHeight*(1-(linePosition!==2)*audioData[i])-_y_dy;
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[i];
context.fillRect(_ux * (i-l_start), _y, _dx, _dy);
roundRect(context, _dx+_ux * (i-l_start), _y-_dx*minv_ratio/2, 0, _dx*minv_ratio, _dx, lc);
roundRect(context, _dx+_ux * (i-l_start), _y+_dx*minv_ratio/2, 0, _dy, _dx, lc);
}
if (centerLineFlag) {
context.fillRect(0, halfHeight-_y_dy-center_width/2, width, center_width);
@ -257,23 +314,26 @@ AdvpStyleTemplate {
} else if (linePosition) {
let _flag = 1-2*(linePosition===1);
_y = halfHeight + halfHeight*(3-2*linePosition)*Boolean(linePosition);
context.fillStyle = line_color;
context.strokeStyle = line_color;
for (let i=l_start; i<r_stop; i++) {
_dy = height*audioData[i]*_flag;
context.fillRect(_ux * (i-l_start), _y, _dx, _dy);
roundRect(context, _dx+_ux * (i-l_start), _y-_dx*minv_ratio/2, 0, _dx*minv_ratio, _dx, lc);
roundRect(context, _dx+_ux * (i-l_start), _y+_dx*minv_ratio/2, 0, _dy, _dx, lc);
}
if (centerLineFlag) {
context.fillRect(0, _y+(linePosition-2)*center_width, width, center_width);
}
} else {
context.fillStyle = line_color;
context.strokeStyle = line_color;
for (let i=l_start; i<r_stop; i++) {
_y = halfHeight*(1-(linePosition!==2)*audioData[i])-_y_dy;
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[i];
context.fillRect(_ux * (i-l_start), _y, _dx, _dy);
roundRect(context, _dx+_ux * (i-l_start), _y-_dx*minv_ratio/2, 0, _dx*minv_ratio, _dx, lc);
roundRect(context, _dx+_ux * (i-l_start), _y+_dx*minv_ratio/2, 0, _dy, _dx, lc);
}
if (centerLineFlag) {
context.fillRect(0, halfHeight-_y_dy-center_width/2, width, center_width);
}
}
}
@ -315,7 +375,7 @@ AdvpStyleTemplate {
}
defaultValues: {
"Version": "1.3.2",
"Version": "1.4.0",
"Gradient Style": 0,
"Linear Gradient Settings": {
"Gradient Direction": 0,
@ -341,6 +401,8 @@ AdvpStyleTemplate {
"Data Length": 0,
"Channel": 2,
"Direction": 0,
"Line Cap": 0,
"Initial Point Size": 0,
"Rotate Settings": {
"Center Enable": false,
"Center Angle": 10,
@ -543,6 +605,23 @@ AdvpStyleTemplate {
model: [qsTr("Left Channel"), qsTr("Right Channel"), qsTr("Stereo")]
}
P.SelectPreference {
name: "Line Cap"
label: qsTr("Line Cap")
defaultValue: defaultValues["Line Cap"]
model: [qsTr("butt"), qsTr("round"), qsTr("square")]
}
P.SliderPreference {
name: "Initial Point Size"
label: qsTr("Initial Point Size")
from: 0
to: 100
stepSize: 1
defaultValue: defaultValues["Initial Point Size"]
displayValue: value + "%"
}
P.Separator {}
P.DialogPreference {

Loading…
Cancel
Save