Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
On 23.07.2017 12:51, Michael Van Canneyt wrote: Agreed. Feel free to submit a patch. Great, I will! Ondrej ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Michael Van Canneyt
Hi, Can you refactor the huge case to use a local proc? it hurts my eyes... Michael. On Sun, 23 Jul 2017, Bart wrote: On 7/23/17, Bart wrote: My try ... Forget previous post... This should make more sense. resourcestring SInvalidHtmlColor = '"%s" is not a

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Bart wrote: > My try ... Forget previous post... This should make more sense. resourcestring SInvalidHtmlColor = '"%s" is not a valid Html color'; { Try to translate HTML color code into TFPColor Supports following formats '#rgb' '#rrggbb'

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Michael Van Canneyt
On Sun, 23 Jul 2017, Bart wrote: On 7/23/17, Michael Van Canneyt wrote: Can you refactor the huge case to use a local proc? it hurts my eyes... Yes I can. But obviously it will keep hurting your eyes, but just in a different place in the sourcecode? I meant

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Michael Van Canneyt wrote: > Can you refactor the huge case to use a local proc? > it hurts my eyes... Yes I can. But obviously it will keep hurting your eyes, but just in a different place in the sourcecode? Bart

[fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
Hello! I couldn't find a function that converts a #RRGGBB color to TFPColor in FPC sources. I only found HTMLToFPColor in Lazarus /trunk/components/tachart/tahtml.pas IMO it is a fairly general function and should be in FPC sources. What do you FPC developers think? Ondrej

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Michael Van Canneyt
On Sun, 23 Jul 2017, Ondrej Pokorny wrote: Hello! I couldn't find a function that converts a #RRGGBB color to TFPColor in FPC sources. I only found HTMLToFPColor in Lazarus /trunk/components/tachart/tahtml.pas IMO it is a fairly general function and should be in FPC sources. What do you

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Ondrej Pokorny wrote: > Great, I will! My try ... { Try to translate HTML color code into TFPColor Supports following formats '#rgb' '#rrggbb' W3C Html color name } function TryHtmlToFPColorDef(const S: String; out FPColor: TFPColor; Def:

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
On 23.07.2017 14:39, Bart wrote: { Try to translate HTML color code into TFPColor Supports following formats '#rgb' '#rrggbb' W3C Html color name } function TryHtmlToFPColorDef(const S: String; out FPColor: TFPColor; Def: TFPColor): Boolean; Actually I wanted to use an

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Bart wrote: Hopefully less eye-sorrow ... resourcestring SInvalidHtmlColor = '"%s" is not a valid Html color'; type THtmlColorName = ( hcnWhite, hcnSilver, hcnGray, hcnBlack, hcnRed, hcnMaroon, hcnYellow, hcnOlive, hcnLime, hcnGreen, hcnAqua,

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
On 23.07.2017 15:25, Michael Van Canneyt wrote: I think the case statement is inefficient enough not to worry about an additional call. There is IdentToInt function in Classes that makes this more efficient. IdentToColor from Graphics.pas uses it as well. Ondrej

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread José Mejuto
El 23/07/2017 a las 16:05, Bart escribió: https://www.w3.org/TR/css3-color/#colorunits Actually, adding more colornames is fine with me, itś just a tedious job ... Hello, If somebody needs it: type HTMLStandardColor=record ColorName: string; Red: BYTE; Green: BYTE; Blue:

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
On 23.07.2017 16:42, Michael Van Canneyt wrote: Inserted this version, without the hcnUnknown. fpimage unit, rev. 36774. Thank you Bart & Michael! I am building FPC trunk right now :) Ondrej ___ fpc-devel maillist - fpc-devel@lists.freepascal.org

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Ondrej Pokorny wrote: > Thank you Bart & Michael! I am building FPC trunk right now :) My pleasure. It was on my private ToDo list anyway. Bart ___ fpc-devel maillist - fpc-devel@lists.freepascal.org

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Michael Van Canneyt
On Sun, 23 Jul 2017, Werner Pamler wrote: Another, related topic would be: Replacement of HTML entities, e.g. convert a string such as 'cmsup2/sup' to 'cm2', or 'sin + cos ' to the one with the correct greek symbols (utf8). I have a solution in TAChart, unit TAHtml, but maybe

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
On 23.07.2017 16:08, Ondrej Pokorny wrote: On 23.07.2017 15:25, Michael Van Canneyt wrote: I think the case statement is inefficient enough not to worry about an additional call. There is IdentToInt function in Classes that makes this more efficient. IdentToColor from Graphics.pas uses it as

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, ListMember wrote: > How about this. To me it is more readable. > > type >THtmlColorName = ( > *hcnUnknown*, hcnWhite, hcnSilver, hcnGray, hcnBlack, I dismissed that idea, becuase now you would have to have an entry in HtmlColorNameToFPColorMap for

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread ListMember
How about this. To me it is more readable. type THtmlColorName = ( *hcnUnknown*, hcnWhite, hcnSilver, hcnGray, hcnBlack, hcnRed, hcnMaroon, hcnYellow, hcnOlive, hcnLime, hcnGreen, hcnAqua, hcnTeal, hcnBlue, hcnNavy, hcnFuchsia, hcnPurple); function TryStrToHtmlColorName(const S:

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Ondrej Pokorny wrote: > +Btw. there are much more name constants: > https://www.w3schools.com/colors/colors_names.asp My set is W3C compliant ... Bart ___ fpc-devel maillist - fpc-devel@lists.freepascal.org

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Michael Van Canneyt
On Sun, 23 Jul 2017, Bart wrote: On 7/23/17, ListMember wrote: How about this. To me it is more readable. type THtmlColorName = ( *hcnUnknown*, hcnWhite, hcnSilver, hcnGray, hcnBlack, I dismissed that idea, becuase now you would have to have an entry in

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Werner Pamler
Another, related topic would be: Replacement of HTML entities, e.g. convert a string such as 'cmsup2/sup' to 'cm2', or 'sin + cos ' to the one with the correct greek symbols (utf8). I have a solution in TAChart, unit TAHtml, but maybe (probably...) there's a better one.

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Ondrej Pokorny
On 23.07.2017 15:50, Bart wrote: On 7/23/17, Ondrej Pokorny wrote: +Btw. there are much more name constants: https://www.w3schools.com/colors/colors_names.asp My set is W3C compliant ... Ah, I see you use only the W3C basic colors

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Bart
On 7/23/17, Ondrej Pokorny wrote: > Ah, I see you use only the W3C basic colors > https://www.w3.org/wiki/CSS/Properties/color/keywords https://www.w3.org/TR/css3-color/#colorunits Actually, adding more colornames is fine with me, itś just a tedious job ... Bart

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Michael Van Canneyt
On Sun, 23 Jul 2017, Werner Pamler wrote: Am 23.07.2017 um 18:09 schrieb Michael Van Canneyt: This exists: function ResolveHTMLEntityReference(const Name: WideString; var Entity: WideChar): Boolean; is in unit htmldefs, fcl-xml package. Thank you. Seeking more carefully would have

Re: [fpc-devel] HTML string to TFPColor

2017-07-23 Thread Werner Pamler
Am 23.07.2017 um 18:09 schrieb Michael Van Canneyt: This exists: function ResolveHTMLEntityReference(const Name: WideString; var Entity: WideChar): Boolean; is in unit htmldefs, fcl-xml package. Thank you. Seeking more carefully would have saved me a lot of tedious typing... Replaced my