WebColours


Contents


Introduction and Overview

On the Internet, formats like HTML, SVG and CSS require the specification of colours. These colour specifications have expanded over time to encompass a number of different ways of expressing the intention. Whilst we commonly see named colours (all English names), numbered colours are more exact but come in many forms. For use in RISC OS applications, the conversion process can be shared and standardised, and has been implemented in the WebColours module.

The WebColours module provides interfaces for converting to and from colour schemes used on the World Wide Web and beyond. There are two major forms that are supported, within which there are more specific specification formats:

  • HTML 4 colours:

    • A short list of named colours is supplied in HTML 4.
    • 24-bit RGB colours specified in hex, in the form '#RRGGBB'.
  • CSS colours (specifically CSS 3)

    • Named HTML 4 colours.
    • Named CSS 3 colours ('X11 colours').
    • 12-bit RGB colours specified in hex, in the form '#RGB'.
    • 24-bit RGB colours specified in decimal, in the form 'rgb(r,g,b)'.
    • Percentage RGB colours specified in decimal in the form 'rgb(r%,g%,b%)'.

The RGB colours that the WebColours module returns are returned in the standard RISC OS form '&BBGGRR00'. The lower 8 bits are reserved for an alpha component which is not currently supported by the module.


SWI calls


WebColours_HTML4ToName
(SWI &54700)

Convert a RISC OS colour to a HTML 4 colour string
On entry
R0=Flags:
Bit(s)Meaning
0Set:Use the named colours.
Clear:Only use the explicit '#' values.
R1=RGB colour in the form &BBGGRR00
R2=Buffer to write the colour string into
R3=Length of the buffer
On exit
R0-2preserved
R3=Buffer length written
Interrupts
Interrupts are undefined
Fast interrupts are undefined
Processor mode
Processor is in undefined mode
Re-entrancy
Not defined
Use

This SWI converts the RISC OS colour value into a string. It can either always convert to the numeric format, or use the readable colour names.

Related SWIs
WebColours_HTML4ToNumber, WebColours_CSSToName

WebColours_HTML4ToNumber
(SWI &54701)

Convert HTML 4 colour string to a RISC OS colour
On entry
R0=Flags:
Bit(s)Meaning
0Set:Allow the named colours to be used.
Clear:Do not check for the named colours.
1Set:String is 0-terminated, R2 is ignored.
Clear:String length in R2 is used.
R1=Pointer to string to convert
R2=Length of the string (only used if flag bit 1 clear)
On exit
R0=RGB colour in the form &BBGGRR00
R1-2preserved
Interrupts
Interrupts are undefined
Fast interrupts are undefined
Processor mode
Processor is in undefined mode
Re-entrancy
Not defined
Use

This SWI converts the HTML 4 colour string int a RISC OS colour value. It can either only convert to the numeric format, or may parse the HTML 4 readable colour names.

Related SWIs
WebColours_HTML4ToName, WebColours_CSSToNumber

WebColours_CSSToName
(SWI &54702)

Convert a RISC OS colour to a CSS 3 colour string
On entry
R0=Flags:
Bit(s)Meaning
0Set:Use the named colours.
Clear:Only use the explicit '#' values.
R1=RGB colour in the form &BBGGRR00
R2=Buffer to write the colour string into
R3=Length of the buffer
On exit
R0-2preserved
R3=Buffer length written
Interrupts
Interrupts are undefined
Fast interrupts are undefined
Processor mode
Processor is in undefined mode
Re-entrancy
Not defined
Use

This SWI is not currently supported.

Related SWIs
WebColours_HTML4ToName, WebColours_CSSToNumber

WebColours_CSSToNumber
(SWI &54703)

Convert CSS 3 colour string to a RISC OS colour
On entry
R0=Flags:
Bit(s)Meaning
1Set:String is 0-terminated, R2 is ignored.
Clear:String length in R2 is used.
8Set:Use the CSS 3 colour names.
Clear:Use the HTML 4 colour names.
R1=Pointer to string to convert
R2=Length of the string (only used if flag bit 1 clear)
On exit
R0=RGB colour in the form &BBGGRR00
R1-2preserved
Interrupts
Interrupts are undefined
Fast interrupts are undefined
Processor mode
Processor is in undefined mode
Re-entrancy
Not defined
Use

This SWI converts the CSS 3 colour string into a RISC OS colour value. The colour names can be processed as CSS 3 or just HTML 4 names.

Related SWIs
WebColours_HTML4ToNumber, WebColours_CSSToName

Document information

Maintainer(s): Charles Ferguson <gerph@gerph.org>
History:
RevisionDateAuthorChanges
0.0715 May 2001GerphInitial version
  • This was the initial release of WebColours with the SVG tools.
0.0719 Sep 2020GerphDocumentation update
  • Documentation written for the module as it currently stands.
Disclaimer:

© Gerph, 2020.