A matter of taste, but...

The "to-do" list for Virtual Radar Server is as long as my arm, but if you want to pile more work onto it then this is for you.
Post Reply
rin67630
Posts: 30
Joined: Fri Jan 08, 2016 9:13 am

A matter of taste, but...

Post by rin67630 » Fri Jan 08, 2016 10:49 am

Dear Andrew,

I know, it is trivial and just a matter of taste, but would it be possible to get the colorizations of the aircraft tracks just the other way round?
Usually the higher the altitude, the more blueish the color, near to the ground it should be red...
That is the convention used by most of the flight trackers.

Thank you for considering this request.
Laszlo

agw
Posts: 1938
Joined: Fri Feb 17, 2012 3:20 am

Re: A matter of taste, but...

Post by agw » Sat Jan 09, 2016 2:09 am

The colours are based on a colour wheel, I nicked the general movement from yellow at low altitude to blue then red at high altitude from FR24.

It's not configurable, the colour wheel conversion is a function. You could replace the function via the custom content plugin if you had your heart set on it :) However I don't generally recommend replacing functions as there's a chance the function might change in some way in a future release. But if you really want to try if then this script would go from red/blue to red to red/green to green to green/blue to blue, with on ground aircraft showing in white and aircraft higher than the maximum altitude that the function can convert shown in bright blue:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.colourHelper) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            VRS.colourHelper.getColourWheelScale = function (value, lowValue, highValue, invalidIsBelowLow, stretchLowerValues) {
                if (invalidIsBelowLow === void 0) { invalidIsBelowLow = true; }
                if (stretchLowerValues === void 0) { stretchLowerValues = true; }
                var result = null;
                if (value === undefined || isNaN(value)) {
                    if (invalidIsBelowLow) result = this.getWhite();
                }
                else if (value <= lowValue) {
                    result = this.getWhite();
                }
                else if (value >= highValue) {
                    result = this.getBlue();
                }
                else {
                    value -= lowValue;
                    var range = (highValue - lowValue) + 1;
                    var fifthRange = range / 5;
                    if (!fifthRange) {
                        result = this.getWhite();
                    } else {
                        if (stretchLowerValues) {
                            if (value < fifthRange) {
                                value *= 2;
                            } else {
                                var newBase = fifthRange * 2;
                                value = Math.round((((value - fifthRange) / (range - fifthRange)) * (range - newBase)) + newBase);
                            }
                        }
                        var fifth = Math.floor(value / fifthRange);
                        var remainder = (value - (fifth * fifthRange)) / fifthRange;
                        var r, g, b;
                        switch (fifth) {
                            case 0:
                                g = 0;
                                r = 255;
                                b = this.fallingComponent(remainder);
                                break;
                            case 1:
                                b = 0;
                                r = 255;
                                g = this.risingComponent(remainder);
                                break;
                            case 2:
                                b = 0;
                                g = 255;
                                r = this.fallingComponent(remainder);
                                break;
                            case 3:
                                r = 0;
                                g = 255;
                                b = this.risingComponent(remainder);
                                break;
                            case 4:
                                r = 0;
                                b = 255;
                                g = this.fallingComponent(remainder);
                                break;
                        }
                        result = { r: r, g: g, b: b };
                    }
                }
                return result;
            };
        });
    }
</script>
If you want to start with bright red and end on bright blue then you need to split the range into 4 instead of 5 - remove the case 4 section and change

Code: Select all

var fifthRange = range / 5;
to

Code: Select all

var fifthRange = range / 4;
and then adjust the other cases so that it starts blue = 0, red = 255, green = rising component, then blue = 0, green = 255 and red = falling component, then red = 0, green = 255 and blue = rising component and then finally red = 0, blue = 255 and green = falling component.

rin67630
Posts: 30
Joined: Fri Jan 08, 2016 9:13 am

Re: A matter of taste, but...

Post by rin67630 » Sat Jan 09, 2016 9:26 pm

Thank you for the fix, i'll test it next week.
Regards
Laszlo

Post Reply