translating a color name to RGB triplet

classic Classic list List threaded Threaded
40 messages Options
12
Reply | Threaded
Open this post in threaded view
|

translating a color name to RGB triplet

KALANGI Vijay BABU
Hi All,

 

Can somebody suggest me a way to "translate a color name to RGB triplet"


 

 

Thanks in advance

 

 

Bubye

Vijay.

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

remove html tags from text

paolo mazza-2
just a simple task for Revolution!
How can I remove html tags from text?

i.e.
from: try  <b> solve<b> this <<httpk.hhkjhlkjlljkl= hkjh> quiz </a>
to:  try   solve  this   quiz

I should use a wildcard  but ....

filter TEXT with "<*>" does not work.  It is only for a list.

I do not want to put the Text in a field and use the HtmlText.

Ciao

Paolo Mazza
********************************************************
Paolo Mazza
NEOL SRL
Via Calatafimi, 16 - 35137 PADOVA
www.neol.it   [hidden email]
Tel 049-7386590

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

masmit
barely tested, but maybe a starting point:

function striptags tHtml
   replace cr with empty in tHtml -- in case of multi-line tags

   replace "<" with cr & "<" in tHtml
   replace ">" with ">" & cr in tHtml

   filter tHtml without "*<*"
   filter tHtml without "*>*"

   return tHtml
end striptags

best,

Mark

On 8 Sep 2006, at 13:52, paolo mazza wrote:

> just a simple task for Revolution!
> How can I remove html tags from text?
>
> i.e.
> from: try  <b> solve<b> this <<httpk.hhkjhlkjlljkl= hkjh> quiz </a>
> to:  try   solve  this   quiz
>
> I should use a wildcard  but ....
>
> filter TEXT with "<*>" does not work.  It is only for a list.
>
> I do not want to put the Text in a field and use the HtmlText.
>
> Ciao
>
> Paolo Mazza
> ********************************************************
> Paolo Mazza
> NEOL SRL
> Via Calatafimi, 16 - 35137 PADOVA
> www.neol.it   [hidden email]
> Tel 049-7386590
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: translating a color name to RGB triplet

david bovill
In reply to this post by KALANGI Vijay BABU
There is no direct way.

So you either have to set some objects color and retrieve it (locking
the screen). Or you have to construct an array or lookup table in
advance and store this somewhere. The former works fine even if
"ugly".
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Jim Ault
In reply to this post by masmit
I would add a loop to clean up the formatting of the returned text, since
html formatting is usually done for the convenience of the programmer, not
the viewer.

On 9/8/06 6:10 AM, "Mark Smith" <[hidden email]> wrote:

> barely tested, but maybe a starting point:
>
> function striptags tHtml
>    replace cr with empty in tHtml -- in case of multi-line tags
>
>    replace "<" with cr & "<" in tHtml
>    replace ">" with ">" & cr in tHtml
>
>    filter tHtml without "*<*"
>    filter tHtml without "*>*"
    repeat for each line LNN in tHtml
      put word 1 to -1 of LNN  & cr after newHtml
   end repeat
   filter newHtml without empty
-- now there are no leading/trailing spaces, no empty lines

replace cr with space in newHtml
--now there are no cr's, since you would not know where they should be if
 --the tags are simply stripped.
--To get the paragraphs of an html page is tricky, since there are several
 --tags and techniques for displaying blocks of text (<p><BR><td><span>)

   return newHtml

>    --return tHtml
> end striptags
>
> best,
>
> Mark
>
> On 8 Sep 2006, at 13:52, paolo mazza wrote:
>
>> just a simple task for Revolution!
>> How can I remove html tags from text?
>>
>> i.e.
>> from: try  <b> solve<b> this <<httpk.hhkjhlkjlljkl= hkjh> quiz </a>
>> to:  try   solve  this   quiz
>>
>> I should use a wildcard  but ....
>>
>> filter TEXT with "<*>" does not work.  It is only for a list.
>>
>> I do not want to put the Text in a field and use the HtmlText.
>>
>> Ciao
>>
>> Paolo Mazza
>> ********************************************************
>> Paolo Mazza
>> NEOL SRL
>> Via Calatafimi, 16 - 35137 PADOVA
>> www.neol.it   [hidden email]
>> Tel 049-7386590
>>
>> _______________________________________________
>> use-revolution mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

mwieder
In reply to this post by masmit
Mark-

Friday, September 8, 2006, 6:10:53 AM, you wrote:

> barely tested, but maybe a starting point:

> function striptags tHtml
>    replace cr with empty in tHtml -- in case of multi-line tags

>    replace "<" with cr & "<" in tHtml
>    replace ">" with ">" & cr in tHtml

>    filter tHtml without "*<*"
>    filter tHtml without "*>*"

>    return tHtml
> end striptags

Clever... but it'll fail on

if xyz > 4096 then

maybe replace the two filter lines with

   filter tHtml without "<*>"

--
-Mark Wieder
 [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Richard Gaskin
In reply to this post by paolo mazza-2
Mark Wieder wrote:

>> function striptags tHtml
>>    replace cr with empty in tHtml -- in case of multi-line tags
>
>>    replace "<" with cr & "<" in tHtml
>>    replace ">" with ">" & cr in tHtml
>
>>    filter tHtml without "*<*"
>>    filter tHtml without "*>*"
>
>>    return tHtml
>> end striptags
>
> Clever... but it'll fail on
>
> if xyz > 4096 then
>
> maybe replace the two filter lines with
>
>    filter tHtml without "<*>"

This is a very interesting topic.

Being a lazy person, historically I've let the engine do the work by
setting the htmlText of a field and then getting that field's text.

But given the overhead of field access, that might not benchmark as well
as doing it in a variable as described here.

Are there any downsides to this approach?  For example, how does it
account for "<" and ">" which may appear in quoted strings or comments?

--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Ken Ray
In reply to this post by paolo mazza-2
On 9/8/06 7:52 AM, "paolo mazza" <[hidden email]> wrote:

> just a simple task for Revolution!
> How can I remove html tags from text?
>
> i.e.
> from: try  <b> solve<b> this <<httpk.hhkjhlkjlljkl= hkjh> quiz </a>
> to:  try   solve  this   quiz
>
> I should use a wildcard  but ....
>
> filter TEXT with "<*>" does not work.  It is only for a list.

Here's what I use... there's two versions - one for "Rev HTML" (i.e. the
version that is generated/managed in Rev):


function stsStripHTML what
  put replaceText(what,"<.*?>","") into noHTML
  return noHTML
end stsStripHTML


and the other is for web pages (because they can contain tags like <script>
<style>, etc. tags that Rev HTML doesn't maintain):


function stsStripHTML what
  put replaceText(what,"(?si)<script.*?/script>","") into what
  put replaceText(what,"(?si)<style.*?/style>","") into what
  put replaceText(what,"<.*?>","") into what
  put replaceText(what,tab,"") into what
  put replaceText(what,CR & "{3,}","") into what
  return what
end stsStripHTML

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: translating a color name to RGB triplet

Ken Ray
In reply to this post by KALANGI Vijay BABU
On 9/8/06 7:32 AM, "KALANGI Vijay BABU" <[hidden email]>
wrote:

> Hi All,
>
>  
>
> Can somebody suggest me a way to "translate a color name to RGB triplet"

Well you need to have a graphic object (like a square) and then execute this
(I called my graphic "ColorHolder"):

function getRGB pColorName
      put the long id of grc "ColorHolder" into tObj
      set the backColor of tObj to pColorName
      set the backPixel of tObj to (the effective backPixel of tObj)
      return (the backColor of tObj)
end getRGB

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

RE: translating a color name to RGB triplet

barryb@libero.it
In reply to this post by KALANGI Vijay BABU
Vijay,
Just  type COLORPICKER into the Google Search window on your web browser and take your PICK.

Barry Barber


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: translating a color name to RGB triplet

Dom-2
In reply to this post by KALANGI Vijay BABU
KALANGI Vijay BABU <[hidden email]> wrote:

> Can somebody suggest me a way to "translate a color name to RGB triplet"

you may also peek at "Color Names Reference" under
"Help/Quick Reference Guides" and see how they translate...
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

masmit
In reply to this post by Richard Gaskin
To reveal yet more of my ignorance, is it likely (certain?) that "<"  
and ">" that are not tag-ends will be urlEncoded (%3C and %3E, I think)?

Best,

Mark

On 8 Sep 2006, at 18:18, Richard Gaskin wrote:

> For example, how does it account for "<" and ">" which may appear  
> in quoted strings or comments?

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

masmit
A little more research suggests that ">" will be "&gt;" (greater  
than) and "<" will be "&lt;" (less than). So I'm guessing that "<"  
and ">" in quoted strings won't be a problem.

What will be a problem is turning "&gt;" back into ">", and all the  
other de-escaping that the htmlText approach takes care of. I guess  
that there is a table of these things somewhere out there, so we'd  
need a function that uses such a table to make sure all our non-tag  
content is ok.

Other than that, the original function, with Mark Wieder and Jim  
Aults additions should handle many simple cases.

Best,

Mark

On 8 Sep 2006, at 20:07, Mark Smith wrote:

> To reveal yet more of my ignorance, is it likely (certain?) that  
> "<" and ">" that are not tag-ends will be urlEncoded (%3C and %3E,  
> I think)?
>
> Best,
>
> Mark
>
> On 8 Sep 2006, at 18:18, Richard Gaskin wrote:
>
>> For example, how does it account for "<" and ">" which may appear  
>> in quoted strings or comments?
>

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: translating a color name to RGB triplet

Stephen Barncard
In reply to this post by Dom-2
somewhere within the bowels of Rev must be a way to convert this directly.

I know you can input colornames to 'Answer Color'

     answer color with "AliceBlue"
     put it into fld "output2"

(it contains 239,247,255)

and of course this works -

       set the backgroundcolor of btn "toadMeat" to "LightYellow"

but when you get the color back from the object

        get colors of btn "toadMeat")
        replace numToChar(11) with return in x
        put it into fld "output2"

you can see "AliceBlue" in line 3 in fld output2.

(I was hoping to see the numbers!!)

hidden table or property?




>KALANGI Vijay BABU <[hidden email]> wrote:
>
>  > Can somebody suggest me a way to "translate a color name to RGB triplet"

--
stephen barncard
s a n  f r a n c i s c o
- - -  - - - - - - - - -
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: translating a color name to RGB triplet

Ken Ray
On 9/8/06 2:29 PM, "Stephen Barncard" <[hidden email]>
wrote:

> somewhere within the bowels of Rev must be a way to convert this directly.
>
> I know you can input colornames to 'Answer Color'
>
>      answer color with "AliceBlue"
>      put it into fld "output2"
>
> (it contains 239,247,255)
>
> and of course this works -
>
>        set the backgroundcolor of btn "toadMeat" to "LightYellow"
>
> but when you get the color back from the object
>
>         get colors of btn "toadMeat")
>         replace numToChar(11) with return in x
>         put it into fld "output2"
>
> you can see "AliceBlue" in line 3 in fld output2.
>
> (I was hoping to see the numbers!!)

Very interesting! If you do the same thing with a graphic, you get the RGB
values back... how odd!

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [hidden email]

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

paolo mazza-2
In reply to this post by masmit
You are great ... so many solutions.

I wuold go for ... (I did not know replaceText command could use wildcard)
... it is fantastic.
I have to say documentation does not mention this.

function stsStripHTML what
  put replaceText(what,"<.*?>","") into noHTML
  return noHTML
end stsStripHTML

I did not know replaceText command could use wildcard as an argument ...
it is fantastic.
I have to say documentation does not mention this.

I am really impressed by your smartness.

Thanks

Paolo Mazza



********************************************************
Paolo Mazza
NEOL SRL
Via Calatafimi, 16 - 35137 PADOVA
www.neol.it   [hidden email]
Tel 049-7386590

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Jim Ault
> I did not know replaceText command could use wildcard as an argument ...
> it is fantastic.

The replaceText function actually uses RegEx, not wildcards.  There is a
major difference.

Filter command -- uses wild cards

ReplaceText, MatchText, MatchChunk functions -- use RegEx


Jim Ault
Las Vegas

On 9/8/06 1:42 PM, "paolo mazza" <[hidden email]> wrote:

> You are great ... so many solutions.
>
> I wuold go for ... (I did not know replaceText command could use wildcard)
> ... it is fantastic.
> I have to say documentation does not mention this.
>
> function stsStripHTML what
>   put replaceText(what,"<.*?>","") into noHTML
>   return noHTML
> end stsStripHTML
>
> I did not know replaceText command could use wildcard as an argument ...
> it is fantastic.
> I have to say documentation does not mention this.
>
> I am really impressed by your smartness.
>
> Thanks
>
> Paolo Mazza
>


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Quentin Long
In reply to this post by paolo mazza-2
In a message dated 9/8/06 11:40:31 AM, Mark Wieder <[hidden email]>
writes:

>Friday, September 8, 2006, 6:10:53 AM, you wrote:
>> barely tested, but maybe a starting point:
>> function striptags tHtml
>>    replace cr with empty in tHtml -- in case of multi-line tags
>>    replace "<" with cr & "<" in tHtml
>>    replace ">" with ">" & cr in tHtml
>>    filter tHtml without "*<*"
>>    filter tHtml without "*>*"
>>    return tHtml
>> end striptags
>Clever... but it'll fail on
>
>if xyz > 4096 then
   No, it won't; not if you're working with an honest-to-God HTML document,
at least. Greater-than and less-than signs are *only* found *in the HTML
source*; if you want either of those symbols to show up when someone views your page
in a browser window, both of them will be HTML entities that start with an
ampersand and end with a semicolon.

>maybe replace the two filter lines with
>
>   filter tHtml without "<*>"
   I don't think there's any need to go that route. Under what circumstances
will you ever encounter a document which includes angle-bracketed HTML tags
*and* leaves honest-to-God angle brackets in their natural, un-Entity-ized state?

--
ANTHRO -- http://anthrozine.com
"It's furry. It's the *good* stuff."
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Jim Ault
Cubist  is correct.  Any well-formed page will have balanced tags and only
use the < and > chars to mean tag markers.

If the data is critical to you, then beware of exceptions.  There could be
incomplete downloads and less-than-professional html code that is received
by Rev which could contain confusing "< >" instances.  This is a good reason
to do the 'one-tag-per-one-line' approach and view the result to locate any
weirdness before trusting the data.

The correct way to tell html to show the viewer a character is
a    <  is &gt;
a    > is  &lt;  
a    &  is  &amp;
and many more for various language characters and high ascii

You could test for an incomplete download by finding the last tag of
"</html>".  If it is missing, you should retry.

Jim Ault
Las Vegas

On 9/8/06 5:09 PM, "[hidden email]" <[hidden email]> wrote:

> In a message dated 9/8/06 11:40:31 AM, Mark Wieder <[hidden email]>
> writes:
>> Friday, September 8, 2006, 6:10:53 AM, you wrote:
>>> barely tested, but maybe a starting point:
>>> function striptags tHtml
>>>    replace cr with empty in tHtml -- in case of multi-line tags
>>>    replace "<" with cr & "<" in tHtml
>>>    replace ">" with ">" & cr in tHtml
>>>    filter tHtml without "*<*"
>>>    filter tHtml without "*>*"
>>>    return tHtml
>>> end striptags
>> Clever... but it'll fail on
>>
>> if xyz > 4096 then
>    No, it won't; not if you're working with an honest-to-God HTML document,
> at least. Greater-than and less-than signs are *only* found *in the HTML
> source*; if you want either of those symbols to show up when someone views
> your page
> in a browser window, both of them will be HTML entities that start with an
> ampersand and end with a semicolon.
>
>> maybe replace the two filter lines with
>>
>>   filter tHtml without "<*>"
>    I don't think there's any need to go that route. Under what circumstances
> will you ever encounter a document which includes angle-bracketed HTML tags
> *and* leaves honest-to-God angle brackets in their natural, un-Entity-ized
> state?


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: remove html tags from text

Richard Gaskin
In reply to this post by paolo mazza-2
Jim Ault wrote:

> Cubist  is correct.  Any well-formed page will have balanced tags and only
> use the < and > chars to mean tag markers.

But can one deliver a product which assumes all the html thrown at it
will be well-formed?

So I have two questions about the sort of variable-based methods for
filtering SGML-style tags and using a field object to so the same:

1. Which is more forgiving of html which may not be well-formed?

2. Which is faster?

--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
12