semi-colon and curly brace stuff for the Rico library.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5015 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -91,16 +91,19 @@ OpenLayers.Rico.Color.createFromHex = function(hexCode) {
|
||||
if(hexCode.length==4) {
|
||||
var shortHexCode = hexCode;
|
||||
var hexCode = '#';
|
||||
for(var i=1;i<4;i++) hexCode += (shortHexCode.charAt(i) +
|
||||
shortHexCode.charAt(i));
|
||||
for(var i=1;i<4;i++) {
|
||||
hexCode += (shortHexCode.charAt(i) +
|
||||
shortHexCode.charAt(i));
|
||||
}
|
||||
}
|
||||
if ( hexCode.indexOf('#') == 0 )
|
||||
hexCode = hexCode.substring(1);
|
||||
if ( hexCode.indexOf('#') == 0 ) {
|
||||
hexCode = hexCode.substring(1);
|
||||
}
|
||||
var red = hexCode.substring(0,2);
|
||||
var green = hexCode.substring(2,4);
|
||||
var blue = hexCode.substring(4,6);
|
||||
return new OpenLayers.Rico.Color( parseInt(red,16), parseInt(green,16), parseInt(blue,16) );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Factory method for creating a color from the background of
|
||||
@@ -113,12 +116,12 @@ OpenLayers.Rico.Color.createColorFromBackground = function(elem) {
|
||||
"backgroundColor",
|
||||
"background-color");
|
||||
|
||||
if ( actualColor == "transparent" && elem.parentNode )
|
||||
if ( actualColor == "transparent" && elem.parentNode ) {
|
||||
return OpenLayers.Rico.Color.createColorFromBackground(elem.parentNode);
|
||||
|
||||
if ( actualColor == null )
|
||||
}
|
||||
if ( actualColor == null ) {
|
||||
return new OpenLayers.Rico.Color(255,255,255);
|
||||
|
||||
}
|
||||
if ( actualColor.indexOf("rgb(") == 0 ) {
|
||||
var colors = actualColor.substring(4, actualColor.length - 1 );
|
||||
var colorArray = colors.split(",");
|
||||
@@ -130,9 +133,10 @@ OpenLayers.Rico.Color.createColorFromBackground = function(elem) {
|
||||
else if ( actualColor.indexOf("#") == 0 ) {
|
||||
return OpenLayers.Rico.Color.createFromHex(actualColor);
|
||||
}
|
||||
else
|
||||
else {
|
||||
return new OpenLayers.Rico.Color(255,255,255);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
|
||||
|
||||
@@ -187,7 +191,7 @@ OpenLayers.Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
|
||||
}
|
||||
|
||||
return { r : parseInt(red), g : parseInt(green) , b : parseInt(blue) };
|
||||
}
|
||||
};
|
||||
|
||||
OpenLayers.Rico.Color.RGBtoHSB = function(r, g, b) {
|
||||
|
||||
@@ -196,38 +200,39 @@ OpenLayers.Rico.Color.RGBtoHSB = function(r, g, b) {
|
||||
var brightness;
|
||||
|
||||
var cmax = (r > g) ? r : g;
|
||||
if (b > cmax)
|
||||
if (b > cmax) {
|
||||
cmax = b;
|
||||
|
||||
}
|
||||
var cmin = (r < g) ? r : g;
|
||||
if (b < cmin)
|
||||
if (b < cmin) {
|
||||
cmin = b;
|
||||
|
||||
}
|
||||
brightness = cmax / 255.0;
|
||||
if (cmax != 0)
|
||||
if (cmax != 0) {
|
||||
saturation = (cmax - cmin)/cmax;
|
||||
else
|
||||
} else {
|
||||
saturation = 0;
|
||||
|
||||
if (saturation == 0)
|
||||
}
|
||||
if (saturation == 0) {
|
||||
hue = 0;
|
||||
else {
|
||||
} else {
|
||||
var redc = (cmax - r)/(cmax - cmin);
|
||||
var greenc = (cmax - g)/(cmax - cmin);
|
||||
var bluec = (cmax - b)/(cmax - cmin);
|
||||
|
||||
if (r == cmax)
|
||||
if (r == cmax) {
|
||||
hue = bluec - greenc;
|
||||
else if (g == cmax)
|
||||
} else if (g == cmax) {
|
||||
hue = 2.0 + redc - bluec;
|
||||
else
|
||||
} else {
|
||||
hue = 4.0 + greenc - redc;
|
||||
|
||||
}
|
||||
hue = hue / 6.0;
|
||||
if (hue < 0)
|
||||
if (hue < 0) {
|
||||
hue = hue + 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
return { h : hue, s : saturation, b : brightness };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user