[#51] Ability to print message with any rgb color#53
[#51] Ability to print message with any rgb color#53dariodsa wants to merge 6 commits intokowainik:mainfrom
Conversation
vrom911
left a comment
There was a problem hiding this comment.
Hey @dariodsa ,
Thanks a lot for your contribution!
I have a few comments/ideas I would like to discuss about this solution.
First of all, I see that the rgbMessage takes a String. I would propose to take 3 Word8 arguments instead and leave all the colour handling to the sRGB24 function of the package.
Also, Haskell supports Hex numbers on a lexical level, so no need to implement a parser here, it should be possible to write 0x.... 🙂
Also, I don't think that the incorrect colour should lead to error. We need to think better, what to do in this case. Maybe just warning and uncoloured text? 🤔
|
Thank you @vrom911 for your comments. Indeed, code now looks much more concise. 😄 So, now when someone tries to run a function with too high or too low literals, Haskell simply cuts its value and continue using it like it is |
chshersh
left a comment
There was a problem hiding this comment.
Hey @dariodsa, the implementation looks good 👍🏻 I left a few comments with some remaining improvements. And I think that relying on GHC warnings (overflow literals specifically) is a good way to go.
Ideally, for the best UI, we would like to have a compile-time compilation and allow literals only of the form 0xABCDEF but there's no easy way to achieve this in Haskell without requiring some heavyweight machinery. So API like rgbMessage 0x00 0x00 0xff looks good for me 👍🏻
|
Hey, @dariodsa. I see there are still some conflicts in this branch with the |
|
Hey @dariodsa! The changes in this PR look great 👍🏻 Thanks for resolving conflicts! I see, that the code mentions the |
Files changed
colourista.cabalsrc/Colourista/IO.hssrc/Colourista/Pure.hsNew behaviour
Added ability to print message using any colour which can be expressed using classic RGB representation (HEX values). If user provides a hex value with a length lower than 6, that value will be truncated with leading zeroes. So
ffwill produce a blue colour.Test
If the PR is going to be accepted, afterwards I can update
README.mdto point the users to the new feature.