⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rounded.js

📁 Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是供中,大型企业来管理其发布在互连网
💻 JS
📖 第 1 页 / 共 2 页
字号:
						var value;
						switch (cc) {
						  case "tr":
							value = (-1 * (Math.abs((this.boxWidth - this.settings[cc].radius + this.borderWidth) + pixelBarLeft) - (Math.abs(this.settings[cc].radius - pixelBarHeight - pixelBarTop - this.borderWidth))));
							pixelBar.style.backgroundPosition = value + "px";
							break;
						  case "tl":
							value = (-1 * (Math.abs((this.settings[cc].radius - pixelBarLeft - 1) - this.borderWidth) - (Math.abs(this.settings[cc].radius - pixelBarHeight - pixelBarTop - this.borderWidth))));
							pixelBar.style.backgroundPosition = value + "px";
							break;
						  case "bl":
							value = (-1 * (Math.abs((this.settings[cc].radius - pixelBarLeft - 1) - this.borderWidth) - (Math.abs((this.boxHeight + this.settings[cc].radius + pixelBarTop) - this.borderWidth))));
							pixelBar.style.backgroundPosition = value + "px";
							break;
						}
					}
				}
			}
			if (newCorner) {
				switch (cc) {
				  case "tl":
					if (newCorner.style.position == "absolute") {
						newCorner.style.top = "0px";
					}
					if (newCorner.style.position == "absolute") {
						newCorner.style.left = "0px";
					}
					if (this.topContainer) {
						this.topContainer.appendChild(newCorner);
					}
					break;
				  case "tr":
					if (newCorner.style.position == "absolute") {
						newCorner.style.top = "0px";
					}
					if (newCorner.style.position == "absolute") {
						newCorner.style.right = "0px";
					}
					if (this.topContainer) {
						this.topContainer.appendChild(newCorner);
					}
					break;
				  case "bl":
					if (newCorner.style.position == "absolute") {
						newCorner.style.bottom = "0px";
					}
					if (newCorner.style.position == "absolute") {
						newCorner.style.left = "0px";
					}
					if (this.bottomContainer) {
						this.bottomContainer.appendChild(newCorner);
					}
					break;
				  case "br":
					if (newCorner.style.position == "absolute") {
						newCorner.style.bottom = "0px";
					}
					if (newCorner.style.position == "absolute") {
						newCorner.style.right = "0px";
					}
					if (this.bottomContainer) {
						this.bottomContainer.appendChild(newCorner);
					}
					break;
				}
			}
		}
		var radiusDiff = [];
		radiusDiff["t"] = this.settings.tl.enabled && this.settings.tr.enabled ? Math.abs(this.settings.tl.radius - this.settings.tr.radius) : 0;
		radiusDiff["b"] = this.settings.bl.enabled && this.settings.br.enabled ? Math.abs(this.settings.bl.radius - this.settings.br.radius) : 0;
		for (var z in radiusDiff) {
			if (radiusDiff[z]) {
				var smallerCornerType = ((this.settings[z + "l"].radius < this.settings[z + "r"].radius) ? z + "l" : z + "r");
				var newFiller = document.createElement("DIV");
				with (newFiller.style) {
					height = radiusDiff[z] + "px";
					width = this.settings[smallerCornerType].radius + "px";
					position = "absolute";
					fontSize = "1px";
					overflow = "hidden";
					backgroundColor = this.boxColour;
				}
				switch (smallerCornerType) {
				  case "tl":
					with (newFiller.style) {
						bottom = "0px";
						left = "0px";
						borderLeft = this.borderString;
					}
					this.topContainer.appendChild(newFiller);
					break;
				  case "tr":
					with (newFiller.style) {
						bottom = "0px";
						right = "0px";
						borderRight = this.borderString;
					}
					this.topContainer.appendChild(newFiller);
					break;
				  case "bl":
					with (newFiller.style) {
						top = "0px";
						left = "0px";
						borderLeft = this.borderString;
					}
					this.bottomContainer.appendChild(newFiller);
					break;
				  case "br":
					with (newFiller.style) {
						top = "0px";
						right = "0px";
						borderRight = this.borderString;
					}
					this.bottomContainer.appendChild(newFiller);
					break;
				}
			}
			var newFillerBar = document.createElement("DIV");
			with (newFillerBar.style) {
				position = "relative";
				fontSize = "1px";
				overflow = "hidden";
				backgroundColor = this.boxColour;
			}
			switch (z) {
			  case "t":
				if (this.topContainer) {
					with (newFillerBar.style) {
						height = topMaxRadius - this.borderWidth + "px";
						marginLeft = this.settings.tl.radius - this.borderWidth + "px";
						marginRight = this.settings.tr.radius - this.borderWidth + "px";
						borderTop = this.borderString;
					}
					this.topContainer.appendChild(newFillerBar);
				}
				break;
			  case "b":
				if (this.bottomContainer) {
					with (newFillerBar.style) {
						height = botMaxRadius - this.borderWidth + "px";
						marginLeft = this.settings.bl.radius - this.borderWidth + "px";
						marginRight = this.settings.br.radius - this.borderWidth + "px";
						borderBottom = this.borderString;
					}
					this.bottomContainer.appendChild(newFillerBar);
				}
				break;
			}
		}
	};
	this.drawPixel = function (intx, inty, colour, transAmount, height, newCorner, image, cornerRadius) {
		var pixel = document.createElement("DIV");
		pixel.style.height = height + "px";
		pixel.style.width = "1px";
		pixel.style.position = "absolute";
		pixel.style.fontSize = "1px";
		pixel.style.overflow = "hidden";
		if (image == -1 && this.backgroundImage != "") {
			pixel.style.backgroundImage = this.backgroundImage;
			pixel.style.backgroundPosition = "-" + (this.boxWidth - (cornerRadius - intx) + this.borderWidth) + "px -" + ((this.boxHeight + cornerRadius + inty) - this.borderWidth) + "px";
		} else {
			pixel.style.backgroundColor = colour;
		}
		if (transAmount != 100) {
			dojo.html.setOpacity(pixel, transAmount);
		}
		pixel.style.top = inty + "px";
		pixel.style.left = intx + "px";
		newCorner.appendChild(pixel);
	};
}, pixelFraction:function (x, y, r) {
	var pixelfraction = 0;
	var xvalues = [];
	var yvalues = [];
	var point = 0;
	var whatsides = "";
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x, 2)));
	if ((intersect >= y) && (intersect < (y + 1))) {
		whatsides = "Left";
		xvalues[point] = 0;
		yvalues[point] = intersect - y;
		point = point + 1;
	}
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y + 1, 2)));
	if ((intersect >= x) && (intersect < (x + 1))) {
		whatsides = whatsides + "Top";
		xvalues[point] = intersect - x;
		yvalues[point] = 1;
		point = point + 1;
	}
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(x + 1, 2)));
	if ((intersect >= y) && (intersect < (y + 1))) {
		whatsides = whatsides + "Right";
		xvalues[point] = 1;
		yvalues[point] = intersect - y;
		point = point + 1;
	}
	var intersect = Math.sqrt((Math.pow(r, 2) - Math.pow(y, 2)));
	if ((intersect >= x) && (intersect < (x + 1))) {
		whatsides = whatsides + "Bottom";
		xvalues[point] = intersect - x;
		yvalues[point] = 0;
	}
	switch (whatsides) {
	  case "LeftRight":
		pixelfraction = Math.min(yvalues[0], yvalues[1]) + ((Math.max(yvalues[0], yvalues[1]) - Math.min(yvalues[0], yvalues[1])) / 2);
		break;
	  case "TopRight":
		pixelfraction = 1 - (((1 - xvalues[0]) * (1 - yvalues[1])) / 2);
		break;
	  case "TopBottom":
		pixelfraction = Math.min(xvalues[0], xvalues[1]) + ((Math.max(xvalues[0], xvalues[1]) - Math.min(xvalues[0], xvalues[1])) / 2);
		break;
	  case "LeftBottom":
		pixelfraction = (yvalues[0] * xvalues[1]) / 2;
		break;
	  default:
		pixelfraction = 1;
	}
	return pixelfraction;
}, rgb2Hex:function (rgbColour) {
	try {
		var rgbArray = this.rgb2Array(rgbColour);
		var red = parseInt(rgbArray[0]);
		var green = parseInt(rgbArray[1]);
		var blue = parseInt(rgbArray[2]);
		var hexColour = "#" + this.intToHex(red) + this.intToHex(green) + this.intToHex(blue);
	}
	catch (e) {
		alert("There was an error converting the RGB value to Hexadecimal in function rgb2Hex");
	}
	return hexColour;
}, intToHex:function (strNum) {
	var base = strNum / 16;
	var rem = strNum % 16;
	var base = base - (rem / 16);
	var baseS = this.makeHex(base);
	var remS = this.makeHex(rem);
	return baseS + "" + remS;
}, makeHex:function (x) {
	if ((x >= 0) && (x <= 9)) {
		return x;
	} else {
		switch (x) {
		  case 10:
			return "A";
		  case 11:
			return "B";
		  case 12:
			return "C";
		  case 13:
			return "D";
		  case 14:
			return "E";
		  case 15:
			return "F";
		}
	}
}, rgb2Array:function (rgbColour) {
	var rgbValues = rgbColour.substring(4, rgbColour.indexOf(")"));
	var rgbArray = rgbValues.split(", ");
	return rgbArray;
}});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -