conveyal / otp.js

OTP Javascript Client & Data Bindings
MIT License
19 stars 20 forks source link

Adds route colors to narrative display for transit legs #43

Closed buma closed 9 years ago

buma commented 9 years ago

It changes background color of otp-Header leg and name of route.

It is shown only if transit legs have routeColor attribute. (It is assumed that routeTextColor also exists)

It doesn't work nicely if routeColor is black. Because arrows and mode icons are also black and are invisible if background is black. Their color can't be changed with text color because they are images.

To fix this they would need to be icon font.

Fixes #40.

abyrd commented 9 years ago

We should probably support the case where routeTextColor is not defined. It should default to black unless the route color is below a certain brightness, in which case it should default to white or a very bright shade of the route color.

buma commented 9 years ago

Google suggests that textColor and routeColor should differ enough that they are clearly legible on black and white screen. W3C and snook are suggested testers.

here is one of the options to calculate colour lightness. I found at least 5 different formulas. Problem is that one colour is mathematically brighter than the other but human eye doesn't perceive colours linearly.

I think it would be better to calculate textColor if it isn't provided on the server. Since if we calculate it on the client each client needs to calculate it separately. But we only calculate it once on the server (when route is read from GTFS if routeColor is provided) and results are consistent.

abyrd commented 9 years ago

Makes sense to me. So we would just look at the background/text color when we load the feed and run it through a check, possibly patching it at that time.