Yet another gem for my Validations library. I should probably separate out the conversion stuff as a conversions library.
Bob S > On Aug 7, 2024, at 11:14 AM, Richard Gaskin via use-livecode > <use-livecode@lists.runrev.com> wrote: > > Paul Dupuis wrote: > >> I can always write a routine to convert RGB to Hex and Hex to RGB, but >> I am wondering if there is some clever trick in Livecode to do this. >> >> For example: answer color -- returns RGB, but the htmlText of a line >> wants <p bgcolor="#NNNNNN"> </p> > > > If the target of the htmlText is a LiveCode field, I don't know of a method > built into the LC engine, but it's easy enough to script: > > function RGBtoHex pColor > repeat for each item tVal in pColor > get baseConvert(tVal, 10, 16) > if len(it) < 2 then put 0 before it > put it after tHex > end repeat > return "#"& tHex > end RGBtoHex > > > If the target of the htmlText is a browser widget, the browser engine's > built-in "rgb" CSS function can do this: > > <html> > <div style="background-color:rgb(130,30,230)"> Hello </div> > </html> > > -- > Richard Gaskin > FourthWorld.com > > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode