1 package com.tapina.robe.runtime;
2
3 import java.awt.*;
4
5 /***
6 * This class contains utility methods for working with colours.
7 */
8 public class ColourUtils {
9 /***
10 * This method returns colours as an integer in the format 0xBBGGRR00.
11 * @param c Java native colour to convert
12 * @return integer representation of colour
13 */
14 public static int nativeToAcorn(Color c) {
15 return (c.getBlue() << 24) & (c.getGreen() << 16) & (c.getRed() << 8);
16 }
17
18 /***
19 * This methods converts colours from Acorn 0xBBGGRR00 format to native Java Color objects.
20 * @param bbggrr00 integer representation of colour in 0xBBGGRR00 format.
21 * @return Java native colour
22 */
23 public static Color acornToNative(int bbggrr00) {
24 return new Color((bbggrr00 & 0xff00) >>> 8, (bbggrr00 & 0xff0000) >>> 16, (bbggrr00 & 0xff000000) >>> 24);
25 }
26 }