示例#1
0
 public HslColor(Number hue, Number saturation, Number lightness, Number alpha)
 {
     Hue = (hue.ToNumber()/360d)%1d;
     Saturation = saturation.Normalize(100d)/100d;
     Lightness = lightness.Normalize(100d)/100d;
     Alpha = alpha.Normalize();
 }
示例#2
0
		public unsafe void Reduce (Number x)
		{
			int k = mod.length, kp1 = k + 1, km1 = k - 1;

			if (x.length < k)
				return;

			Number q = new Number (x.length - km1 + constant.length);
			Number r = new Number (kp1);
			fixed (uint* pq = q.data, pr = r.data, pm = mod.data, px = x.data, pc = constant.data) {
				Number.Multiply (px + km1, x.length - km1, pc, constant.length, pq);

				x.length = (x.length > kp1 ? kp1 : x.length);
				x.Normalize ();

				uint* xs = pq + kp1, xe = xs + q.length - kp1;
				uint* ys = pm, ye = ys + mod.length;
				uint* zs = pr, ze = zs + kp1;

				for (; xs < xe; xs++, zs++) {
					if (*xs == 0) continue;
					ulong carry = 0;
					uint* zp = zs;
					for (uint* yp = ys; yp < ye && zp < ze; yp++, zp++) {
						carry += ((ulong)*xs) * ((ulong)*yp) + ((ulong)*zp);
						*zp = (uint)carry;
						carry >>= 32;
					}
					if (carry != 0 && zp < ze)
						*zp = (uint)carry;
				}
				r.Normalize ();

				if (r.CompareTo (x) <= 0) {
					x.length = Number.Subtract (px, x.length, pr, r.length, px);
				} else {
					Number val = new Number (kp1 + 1);
					val.data[kp1] = 1;
					fixed (uint* pv = val.data) {
						val.length = Number.Subtract (pv, val.length, pr, r.length, pv);
						x.length = Number.Add (px, x.length, pv, val.length, px);
					}
				}
				x.Normalize ();

				while (x.CompareTo (mod) >= 0) {
					x.length = Number.Subtract (px, x.length, pm, mod.length, px);
				}
			}
		}