diff --git a/README.md b/README.md index dbc526a..9873821 100644 --- a/README.md +++ b/README.md @@ -118,12 +118,13 @@ curl -k --anyauth -u root: \ will list the current settings: ```sh -root.findwind.FindwindSpotID=301 -root.findwind.Style=1A -root.findwind.Opacity=0.7 -root.findwind.Position=topLeft -root.findwind.CustomPositionX=0 -root.findwind.CustomPositionY=0 +root.Findwind.CustomPositionX=0 +root.Findwind.CustomPositionY=0 +root.Findwind.FindwindSpotID=301 +root.Findwind.Opacity=0.7 +root.Findwind.Position=topLeft +root.Findwind.Scale=100 +root.Findwind.Style=1A ``` > [!TIP] @@ -137,13 +138,18 @@ root.findwind.CustomPositionY=0 > *topLeft/topRight/bottomLeft/bottomRight/custom* and *CustomPositionX* > and *CustomPositionY* must be within the range -1.0 to 1.0. -If you want to set the opacity to e.g. 0.8: +If you want to set the style to e.g. 1B: ```sh curl -k --anyauth -u root: \ - 'https:///axis-cgi/param.cgi?action=update&root.findwind.Opacity=0.8' + 'https:///axis-cgi/param.cgi?action=update&root.findwind.Style=1B' ``` +> [!TIP] +> The *Scale* parameter is a percentage value that scales the overlay size. +> For example, a scale of 200 will double the size of the overlay, while +> a scale of 50 will reduce it to half size. + ## Usage Once configured and running, the application will overlay wind information on the camera's video stream. The overlay updates periodically (default every 120 seconds) with the latest data from FindWind. diff --git a/findwind b/findwind index 0fcf7e3..520a081 100755 --- a/findwind +++ b/findwind @@ -258,19 +258,33 @@ download_svg() { # Replace font-family with a known sans-serif font to improve chances of correct rendering (since the original font may not be available in the container) # and set opacity on the first tag regardless of existing attributes. opacity=$(get_non_empty_param Opacity) - echo "$svg" | \ - sed -e "s#\(font-family='\)[^']*'#\1$FONT_FAMILY'#g" \ - -e "s#\(font-family=\"\)[^\"]*\"#\1$FONT_FAMILY\"#g" \ - -e "1,/]*>/s#]*>##" | \ + svg=$(echo "$svg" |sed -e "s#\(font-family='\)[^']*'#\1$FONT_FAMILY'#g" \ + -e "s#\(font-family=\"\)[^\"]*\"#\1$FONT_FAMILY\"#g" \ + -e "1,/]*>/s#]*>##" | \ "$BASEDIR/usvg" \ --quiet \ --indent 0 \ --skip-system-fonts \ --use-fonts-dir "$FINDWIND_FONTS_DIR" \ - - "$1" || { + - -c) || { croak 'failed to render SVG text' return 1 } + + # Handle eventual scaling (with the consistent usvg output, strict format + # assumptions works and simplifies substitions). + scale=$(get_non_empty_param Scale) + [ "$scale" -eq 100 ] || { + dimensions=${svg%% xmlns*} + width=${dimensions##*width=\"} + width=${width%%\"*} + height=${dimensions##*height=\"} + height=${height%%\"*} + newwidth=$((width * scale / 100)) + newheight=$((height * scale / 100)) + svg=$(echo "$svg" |sed "s/ "$1" } create_tmp_svg_file() { diff --git a/manifest.json b/manifest.json index d1c378b..5d094ee 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "vendorUrl": "https://github.com/d97jro", "vendorId": "1234567890", "runMode": "respawn", - "version": "1.1.1", + "version": "1.1.2", "compatibleOsVersions": [ { "max": "13" @@ -37,6 +37,11 @@ "type": "enum:topLeft|Top left, topRight|Top right, bottomLeft|Bottom left, bottomRight|Bottom right, custom|Custom position", "default": "topLeft" }, + { + "name": "Scale", + "type": "int:min=10,max=900", + "default": "100" + }, { "name": "CustomPositionX", "type": "double:min=-1,max=1",