public Scene(RGBColor iamb, NameableCollection<Light> lights, Camera defaultCamera, float refractIndice) { this.IAmb = iamb; this.RefractIndex = refractIndice; if (lights != null) { this.Lights = new NameableCollection<Light>(lights); } else { this.Lights = new NameableCollection<Light>(); } this.primitives = new NameableCollection<Primitive>(); this.AccelerationStructure = new KDTreePrimitiveManager(this.primitives as IList<Primitive>); this.materials = new NameableCollection<Material>(); this.DefaultCamera = defaultCamera; this.Cameras = new NameableCollection<Camera>(); if (defaultCamera != null) { this.Cameras.Add(defaultCamera); } this.sampler = new JitteredSampler(); this.shader = new PhongShader(this); this.renderStrategy = new ScanlineRenderStrategy(); this.isShadowActive = false; this.softShadowSamples = 8; this.glossySamples = 8; //this.cameras.CollectionChanged += new NotifyCollectionChangedEventHandler<Camera>(cameras_CollectionChanged); }
public Photon(Vector3D dir, Point3D pos, RGBColor power) { //CalculatePhiTheta(dir); this.Direction = dir; this.Power = power; this.Position = pos; }
public Photon(Photon p) { this.Position = p.Position; this.Plane = p.Plane; this.Theta = p.Theta; this.Phi = p.Phi; this.Power = p.Power; }
public static LightCommand SetColor(this LightCommand lightCommand, RGBColor color, string model = "LCT001") { if (lightCommand == null) throw new ArgumentNullException(nameof(lightCommand)); var point = HueColorConverter.CalculateXY(color, model); return lightCommand.SetColor(point.x, point.y); }
public HSBColor(RGBColor color) { HSBColor temp = FromColor(color); this.A = temp.A; this.H = temp.H; this.S = temp.S; this.B = temp.B; }
public ViewModel() { // Set default colour to white, full brightness rgbColor = new RGBColor(1.0f, 1.0f, 1.0f); hsvColor = new HSVColor(0.0f, 0.0f, 1.0f); temperature = ColorTemperature.Neutral; brightness = 1.0f; ColorChanged(); }
/// <summary> /// Adapts RGB color from the source working space to working space set in <see cref="TargetRGBWorkingSpace"/>. /// </summary> public RGBColor Adapt(RGBColor color) { if (color == null) throw new ArgumentNullException("color"); var linearInput = ToLinearRGB(color); var linearOutput = Adapt(linearInput); var compandedOutput = ToRGB(linearOutput); return compandedOutput; }
public Definition() { _isVisible = true; Alignment = ToolbarAlignmentEnum.Top; AnimationDuration = 0.25f; BackgroundColor = new RGBColor(0xf45f00); ItemSpacing = 12.0f; Breadth = 44.0f + ItemSpacing*2; PrimaryItemAlignment = ToolbarAlignmentEnum.Left; }
public override RGBColor F(ShadeRec shadeRec, Vector3d wi, Vector3d wo) { RGBColor L = new RGBColor(); double NdotWi = Vector3d.Dot(shadeRec.Normal, wi); Vector3d r = (-wi + (Vector3d)shadeRec.Normal * NdotWi * 2); double RdotWo = Vector3d.Dot(r, wo); if (RdotWo > 0) { L = CS*KS*Math.Pow(RdotWo, Exp); } return L; }
public static LightCommand SetColor(this LightCommand lightCommand, RGBColor color) { if (lightCommand == null) throw new ArgumentNullException(nameof(lightCommand)); var hsb = color.GetHSB(); lightCommand.Brightness = (byte)hsb.Brightness; lightCommand.Hue = hsb.Hue; lightCommand.Saturation = hsb.Saturation; return lightCommand; }
public override void RenderScene(World world) { //Stopwatch sw = Stopwatch.StartNew(); //while (true) //{ // sw.Restart(); RGBColor L = new RGBColor(); ViewPlane viewPlane = (ViewPlane) world.ViewPlane.Clone(); Ray ray = new Ray(); int depth = 0; Point2d samplePoint = new Point2d(); Point2d pixelPoint = new Point2d(); viewPlane.PixelSize /= zoom; ray.Origin = Eye; Bitmap bitmap = new Bitmap(viewPlane.HRes, viewPlane.VRes); for (int r = 0; r < viewPlane.VRes; r++) { for (int c = 0; c < viewPlane.HRes; c++) { L = new RGBColor(0, 0, 0); for (int i = 0; i < viewPlane.Sampler.NumSamples; i++) { samplePoint = viewPlane.Sampler.SampleUnitSquare(); pixelPoint.X = viewPlane.PixelSize*(c - 0.5*viewPlane.HRes + samplePoint.X); pixelPoint.Y = viewPlane.PixelSize*(r - 0.5*viewPlane.VRes + samplePoint.Y); ray.Direction = GetRayDirection(pixelPoint); L += world.Tracer.TraceRay(ray, depth); } L /= viewPlane.Sampler.NumSamples; L *= eposureTime; L.MaxToOne(); bitmap.SetPixel(c, viewPlane.VRes - r - 1, Color.FromArgb((int) (L.R*255), (int) (L.G*255), (int) (L.B*255))); } Console.Out.WriteLine("r = {0}", r); } bitmap.Save("TracedImage.bmp", ImageFormat.Bmp); //Console.Out.WriteLine("sw = {0}", sw.ElapsedMilliseconds); }
public RGBColor Radiance(HitInfo info, int depth) { Vector3 toCameraDirection = -info.Ray.direction; RGBColor radiance = direct.Radiance(info, depth); Vector3 reflectionDirection = Vector3.Reflect(toCameraDirection, info.Normal); Ray reflectedRay = new Ray(info.HitPoint, reflectionDirection); radiance += info.World.tracer.ShadeRay(info.World, reflectedRay, ref depth) * reflectionColor * reflectivity; return(radiance); }
public static float GetSaturation(Color color) { RGBColor maxColor = GetMax(color); RGBColor minColor = GetMin(color); float delta = maxColor.value - minColor.value; if (delta == 0) { return(0); } return(delta / (1 - Mathf.Abs(2 * GetLightness(color) - 1))); }
public PixelAnimator(RGBColor currentColor, RGBColor targetColor, int steps) { _steps = steps; _targetColor = targetColor; _red = (uint16_t)(currentColor.red << 8); _green = (uint16_t)(currentColor.green << 8); _blue = (uint16_t)(currentColor.blue << 8); _redDelta = (uint16_t)(((targetColor.red - currentColor.red) << 8) / steps); _greenDelta = (uint16_t)(((targetColor.green - currentColor.green) << 8) / steps); _blueDelta = (uint16_t)(((targetColor.blue - currentColor.blue) << 8) / steps); }
public void renderAndShow(Chunk chunk) { var numPixels = _strip.numPixels(); for (uint16_t i = 0; i < numPixels; i++) { RGBColor color = chunk.getNextPixel(); _strip.setPixelColor(i, color.red, color.green, color.blue); } _strip.show(); }
public override RGBColor F(ShadeRec shadeRec, Vector3d wi, Vector3d wo) { RGBColor L = new RGBColor(); double NdotWi = Vector3d.Dot(shadeRec.Normal, wi); Vector3d r = (-wi + (Vector3d)shadeRec.Normal * NdotWi * 2); double RdotWo = Vector3d.Dot(r, wo); if (RdotWo > 0) { L = CS * KS * Math.Pow(RdotWo, Exp); } return(L); }
public async Task TurnOnLight(RGBColor RgbColor, byte Brightness, List <string> lights) { try { var command = new LightCommand(); command.TurnOn().SetColor(RgbColor); command.Brightness = Brightness; await client.SendCommandAsync(command, lights); } catch { } }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { if (!color.HasValue) { color = RGBColor.Random(); } var fronToBack = layer.GroupBy(x => (int)(((x.LightLocation.Y + 1) / 2) * 50)).ToList(); Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds * 2) / fronToBack.Count); return(fronToBack.FlashQuick(cancellationToken, color, IteratorEffectMode.Bounce, IteratorEffectMode.All, waitTime: customWaitMS)); }
/// <summary> /// Adapts RGB color from the source working space to working space set in <see cref="TargetRGBWorkingSpace"/>. /// </summary> public RGBColor Adapt(RGBColor color) { if (color == null) { throw new ArgumentNullException("color"); } var linearInput = ToLinearRGB(color); var linearOutput = Adapt(linearInput); var compandedOutput = ToRGB(linearOutput); return(compandedOutput); }
public ScrapOptionData() { this.InactiveAlphaValue = 90; this.InactiveLineChange = false; this.InactiveLineValue = 1; this.InactiveLineColor = new RGBColor(0, 0, 0); this.MouseOverAlphaChange = true; this.MouseOverAlphaValue = 10; this.MouseOverLineChange = false; this.MouseOverLineValue = 1; this.MouseOverLineColor = new RGBColor(0, 0, 0); this.SubMenuStyles = new List <int>(); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { if (!color.HasValue) { color = RGBColor.Random(); } var groupCount = layer.Count / 3; Func <TimeSpan> customWaitMS = () => TimeSpan.FromMilliseconds((waitTime().TotalMilliseconds * 2) / groupCount); return(layer.OrderBy(x => Guid.NewGuid()).ChunkByGroupNumber(groupCount).FlashQuick(cancellationToken, color, IteratorEffectMode.Random, waitTime: customWaitMS)); }
public static Task Flash(this IEnumerable <IEnumerable <EntertainmentLight> > group, CancellationToken cancellationToken, RGBColor?color, IteratorEffectMode mode = IteratorEffectMode.Cycle, IteratorEffectMode secondaryIteratorMode = IteratorEffectMode.All, Ref <TimeSpan?> waitTime = null, Ref <TimeSpan?> onTime = null, Ref <TimeSpan?> transitionTimeOn = null, Ref <TimeSpan?> transitionTimeOff = null, bool waitTillFinished = true, TimeSpan?duration = null) { if (!color.HasValue) { var r = new Random(); color = new RGBColor(r.NextDouble(), r.NextDouble(), r.NextDouble()); } if (waitTime == null) { waitTime = TimeSpan.FromMilliseconds(50); } if (onTime == null) { onTime = waitTime; } if (transitionTimeOn == null) { transitionTimeOn = TimeSpan.FromMilliseconds(0); } if (transitionTimeOff == null) { transitionTimeOff = TimeSpan.FromMilliseconds(0); } Ref <TimeSpan?> actualWaitTime = waitTime.Value + onTime.Value + transitionTimeOn.Value + transitionTimeOff.Value; if (!waitTillFinished) { actualWaitTime = waitTime.Value; } return(group.IteratorEffect(cancellationToken, async(current, ct, t) => { if (!waitTillFinished) { actualWaitTime.Value = waitTime.Value; } else { actualWaitTime.Value = waitTime.Value.Value + onTime.Value.Value + transitionTimeOn.Value.Value + transitionTimeOff.Value.Value; } current.SetState(ct, color, 1, transitionTimeOn.Value.Value); Task.Run(async() => { await Task.Delay(onTime.Value.Value + transitionTimeOn.Value.Value, ct).ConfigureAwait(false); current.SetBrightness(ct, 0, transitionTimeOff.Value.Value); }, ct); }, mode, secondaryIteratorMode, actualWaitTime, duration)); }
/// <summary> /// Updates the outputs of the RGBAToy. /// </summary> public override void UpdateOutputs() { if (OutputController != null && Layers.Count > 0) { RGBColor RGB = GetResultingData(); int OutputNumber = 0; switch (ColorOrder) { case RGBOrderEnum.RBG: OutputData[OutputNumber] = FadingCurve.MapValue(RGB.Red); OutputData[OutputNumber + 2] = FadingCurve.MapValue(RGB.Green); OutputData[OutputNumber + 1] = FadingCurve.MapValue(RGB.Blue); break; case RGBOrderEnum.GRB: OutputData[OutputNumber] = FadingCurve.MapValue(RGB.Green); OutputData[OutputNumber + 1] = FadingCurve.MapValue(RGB.Red); OutputData[OutputNumber + 2] = FadingCurve.MapValue(RGB.Blue); break; case RGBOrderEnum.GBR: OutputData[OutputNumber] = FadingCurve.MapValue(RGB.Green); OutputData[OutputNumber + 1] = FadingCurve.MapValue(RGB.Blue); OutputData[OutputNumber + 2] = FadingCurve.MapValue(RGB.Red); break; case RGBOrderEnum.BRG: OutputData[OutputNumber] = FadingCurve.MapValue(RGB.Blue); OutputData[OutputNumber + 1] = FadingCurve.MapValue(RGB.Red); OutputData[OutputNumber + 2] = FadingCurve.MapValue(RGB.Green); break; case RGBOrderEnum.BGR: OutputData[OutputNumber] = FadingCurve.MapValue(RGB.Blue); OutputData[OutputNumber + 1] = FadingCurve.MapValue(RGB.Green); OutputData[OutputNumber + 2] = FadingCurve.MapValue(RGB.Red); break; case RGBOrderEnum.RGB: default: OutputData[OutputNumber] = FadingCurve.MapValue(RGB.Red); OutputData[OutputNumber + 1] = FadingCurve.MapValue(RGB.Green); OutputData[OutputNumber + 2] = FadingCurve.MapValue(RGB.Blue); break; } OutputController.SetValues((LedNumber - 1) * 3, OutputData); } ; }
public override void RenderScene(World world) { //Stopwatch sw = Stopwatch.StartNew(); //while (true) //{ // sw.Restart(); RGBColor L = new RGBColor(); ViewPlane viewPlane = (ViewPlane)world.ViewPlane.Clone(); Ray ray = new Ray(); int depth = 0; Point2d samplePoint = new Point2d(); Point2d pixelPoint = new Point2d(); viewPlane.PixelSize /= zoom; ray.Origin = Eye; Bitmap bitmap = new Bitmap(viewPlane.HRes, viewPlane.VRes); for (int r = 0; r < viewPlane.VRes; r++) { for (int c = 0; c < viewPlane.HRes; c++) { L = new RGBColor(0, 0, 0); for (int i = 0; i < viewPlane.Sampler.NumSamples; i++) { samplePoint = viewPlane.Sampler.SampleUnitSquare(); pixelPoint.X = viewPlane.PixelSize * (c - 0.5 * viewPlane.HRes + samplePoint.X); pixelPoint.Y = viewPlane.PixelSize * (r - 0.5 * viewPlane.VRes + samplePoint.Y); ray.Direction = GetRayDirection(pixelPoint); L += world.Tracer.TraceRay(ray, depth); } L /= viewPlane.Sampler.NumSamples; L *= eposureTime; L.MaxToOne(); bitmap.SetPixel(c, viewPlane.VRes - r - 1, Color.FromArgb((int)(L.R * 255), (int)(L.G * 255), (int)(L.B * 255))); } Console.Out.WriteLine("r = {0}", r); } bitmap.Save("TracedImage.bmp", ImageFormat.Bmp); //Console.Out.WriteLine("sw = {0}", sw.ElapsedMilliseconds); }
public HelloWorldScene() : base(ambient: RGBColor.FromRGB(0.15)) { AddShape(new Circle(new Vector2(0), 0.15, Materials.WhiteLight)); int n = 6; float r = 0.5f; for (float i = 0; i < 6; i++) { var theta = 2.0 * Math.PI * i / n; (var x, var y) = (r * Math.Cos(theta), r *Math.Sin(theta)); AddShape(new Circle(new Vector2(x, y), radius: 0.08, Materials.Default)); } }
/// <summary> /// (Private) Adds a new <see cref="UIControl"/> on the page. /// </summary> /// <typeparam name="T">The type of <see cref="UIControl"/> to create</typeparam> /// <returns>The new <see cref="UIControl"/></returns> private T AddControl <T>(int x, int y, RGBColor color, int tilemap) where T : UIControl, new() { T control = new T(); control.Initialize(this); Controls.Add(control); control.Position = new Position(x, y); control.Color = color; control.Tilemap = tilemap; UI.Invalidate(); return(control); }
override public RGBColor GetColor(double value) { var c = new RGBColor(); foreach (ColorScaleValue csval in _colorScale) { if (value < csval.UpperLimit && value >= csval.LowerLimit) { c = csval.GetColor(value); break; } } return(c); }
override public RGBColor GetColor(bool value) { var c = new RGBColor(); if (value) { c = _colorValue.ColorTrue; } else { c = _colorValue.ColorFalse; } return(c); }
public void Convert_sRGB_to_XYZ_D65(double r, double g, double b, double x, double y, double z) { // arrange var input = new RGBColor(r, g, b); var converter = new ColourfulConverter { WhitePoint = Illuminants.D65 }; // act XYZColor output = converter.ToXYZ(input); // assert Assert.That(output.X, Is.EqualTo(x).Using(DoubleComparer)); Assert.That(output.Y, Is.EqualTo(y).Using(DoubleComparer)); Assert.That(output.Z, Is.EqualTo(z).Using(DoubleComparer)); }
private void TcpClientOnDelimiterDataReceived(object sender, Message message) { List <(LedId, Color)> leds = message.MessageString.Split(';').Select(x => { string[] led = x.Split('|'); return((LedId)Enum.Parse(typeof(LedId), led[0]), RGBColor.FromHexString(led[1])); }).ToList(); lock (_syncbackCache) foreach ((LedId ledId, Color color) in leds) { _syncbackCache[ledId] = color; } }
public async Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { if (!color.HasValue) { color = RGBColor.Random(); } layer.SetState(cancellationToken, color, 1, waitTime(), false); //Wait for other events to finish and set state again await Task.Delay(waitTime(), cancellationToken); layer.SetState(cancellationToken, color, 1, waitTime(), false); }
protected override MutableObject Mutate(MutableObject mutable) { foreach (var entry in RGBColor.GetEntries(mutable)) { float outH, outS, outV; ColorUtility.RGBToHSV(RGBColor.GetValue(entry), out outH, out outS, out outV); HTarget.SetValue(outH, entry); STarget.SetValue(outS, entry); VTarget.SetValue(outV, entry); } return(mutable); }
/// <summary> /// Sets the color of the common command. /// </summary> /// <param name="rgbColor">New color in the color type of the API</param> public static void SetRGBColorInCommonCommand(RGBColor rgbColor) { if (!canControl) { return; } if (BridgeInformation.demoMode) { DemoLightController.commonRGBColor = rgbColor; } commonLightCommand.SetColor(rgbColor); }
public static Color Lab2Color(LabColor color) { Color output = new Color(); var converter = new ColourfulConverter { WhitePoint = Illuminants.D50, TargetRGBWorkingSpace = RGBWorkingSpaces.sRGB }; RGBColor rgbColor = converter.ToRGB(color); output.r = (float)rgbColor.R; output.g = (float)rgbColor.G; output.b = (float)rgbColor.B; output.a = 1.0f; return(output); }
public ShapesScene() : base(ambient: RGBColor.FromRGB(0.15)) { var circle = new Circle(new Vector2(-0.5, 0.5), 0.25, Materials.WhiteLight); AddShape(circle); var rectangle = new Rectangle(new Vector2(0.5, 0.5), new Vector2(0.25), Materials.WhiteLight); AddShape(rectangle); var triangle = new Triangle(new Vector2(-0.5, -0.5), 0.25, Materials.WhiteLight); AddShape(triangle); }
public static Color ConvertRGBColorToColor(RGBColor inputRGBColor) { string hexCode = inputRGBColor.ToHex(); Color color = new Color { A = 255, R = byte.Parse(hexCode.Substring(0, 2), NumberStyles.HexNumber), G = byte.Parse(hexCode.Substring(2, 2), NumberStyles.HexNumber), B = byte.Parse(hexCode.Substring(4, 2), NumberStyles.HexNumber), }; return(color); }
public override RGBColor Trace(Ray ray, int depth) { Intersection intersection; if (this.scene.FindIntersection(ray, out intersection)) { Material material = intersection.HitPrimitive.Material; Shader shader = material.CreateShader(this.scene); RGBColor color = shader.Shade(ray, intersection); Ray rRay = new Ray(); if (depth < 5) { if (material.IsReflective) { rRay.Origin = intersection.HitPoint; rRay.Direction = Vector3D.Reflected(intersection.Normal, ray.Direction); color += this.indirectEnlightenment.IrradianceEstimate(intersection.HitPoint, intersection.Normal, this.IrradianceArea, this.IrradiancePhotonNumber); //color += this.Trace(rRay, depth + 1) * material.KSpec; this.Trace(rRay, depth + 1); } if (material.IsTransparent) { Vector3D T; //float eta = intersection.HitFromInSide // ? material.RefractIndex * 1 / this.scene.RefractIndex // : this.scene.RefractIndex * 1 / material.RefractIndex; //float eta = this.scene.RefractIndex * 1 / material.RefractIndex; float eta = (ray.PrevRefractIndex.IsEqual(material.RefractIndex)) ? material.RefractIndex * 1 / this.scene.RefractIndex : this.scene.RefractIndex * 1 / material.RefractIndex; if (Vector3D.Refracted(intersection.Normal, ray.Direction, out T, eta)) { rRay.Origin = intersection.HitPoint; rRay.Direction = T; rRay.PrevRefractIndex = material.RefractIndex; color += this.indirectEnlightenment.IrradianceEstimate(intersection.HitPoint, intersection.Normal, this.IrradianceArea, this.IrradiancePhotonNumber); this.Trace(rRay, depth + 1); //* material.KTrans } } } return(color); } return(this.scene.IsEnvironmentMapped ? this.scene.EnvironmentMap.GetColor(ray) : this.scene.BackgroundColor); }
public static LightCommand SetColor(this LightCommand lightCommand, RGBColor color) { if (lightCommand == null) { throw new ArgumentNullException(nameof(lightCommand)); } var hsb = color.GetHSB(); lightCommand.Brightness = (byte)hsb.Brightness; lightCommand.Hue = hsb.Hue; lightCommand.Saturation = hsb.Saturation; return(lightCommand); }
public Palette(IStreamReader reader, RecordType id, UInt16 length) : base(reader, id, length) { // assert that the correct record type is instantiated Debug.Assert(this.Id == ID); this.rgbColorList = new List <RGBColor>(); this.ccv = reader.ReadUInt16(); for (int i = 0; i < this.ccv; i++) { RGBColor color = new RGBColor(reader.ReadInt32(), RGBColor.ByteOrder.RedFirst); this.rgbColorList.Add(color); } }
public static double GetSaturation(this RGBColor rgb) { var R = rgb.R; var G = rgb.G; var B = rgb.B; var min = Numbers.Min(R, G, B); var max = Numbers.Max(R, G, B); if (max.AlmostEquals(min)) { return(0); } return(((max.AlmostEquals(0f)) ? 0f : 1f - (1f * min / max)) * 255); }
public Task Start(EntertainmentLayer layer, Func <TimeSpan> waitTime, RGBColor?color, CancellationToken cancellationToken) { //Non repeating effects should not run on baselayer if (layer.IsBaseLayer) { return(Task.CompletedTask); } if (!color.HasValue) { color = RGBColor.Random(); } return(layer.To2DGroup().FlashQuick(cancellationToken, color, IteratorEffectMode.All, IteratorEffectMode.All, waitTime: () => TimeSpan.FromMilliseconds(100), transitionTimeOn: () => TimeSpan.Zero, transitionTimeOff: waitTime, duration: waitTime())); }
public void ColorConversionDarkSeaGreenPoint() { string color = "8FBC8B"; RGBColor rgbColor = new RGBColor(color); var hsb = rgbColor.GetHSB(); State state = new State() { Hue = hsb.Hue, Brightness = (byte)hsb.Brightness, Saturation = hsb.Saturation }; var rgb = state.ToRgb(); }
protected Material() { this.absorptivity = 0.3f; this.glossy = 0.1f; this.kDiff = 0.5f; this.kSpec = 0.5f; this.kTrans = 0.0f; this.kAmb = 0.1f; this.diffuseColor = RGBColor.White; this.specularColor = RGBColor.White; this.refractIndex = 1.51f; this.shiness = 64; this.isTexturized = false; this.texture = new Texture(); }
//Copy constructor public ShadeRec(ShadeRec shadeRec) { HitAnObject = shadeRec.HitAnObject; ObjectMaterial = shadeRec.ObjectMaterial; HitPoint = shadeRec.HitPoint; HitPointLocal = shadeRec.HitPointLocal; Normal = shadeRec.Normal; Color = shadeRec.Color; WorldPointer = shadeRec.WorldPointer; Ray = shadeRec.Ray; RecursionDepth = shadeRec.RecursionDepth; Direction = shadeRec.Direction; TMinimum = shadeRec.TMinimum; U = shadeRec.U; V = shadeRec.V; }
//Constructor public ShadeRec(World worldRef) { HitAnObject = false; ObjectMaterial = null; RecursionDepth = 0; WorldPointer = worldRef; HitPoint = new Point3D(0, 0, 0); HitPointLocal = new Point3D(0, 0, 0); Normal = new Normal(0, 0, 0); Color = new RGBColor(0, 0, 0); TMinimum = GlobalVars.K_HUGE_VALUE; Ray = new Ray(new Point3D(0, 0, 0), new Vect3D(0, 0, 0)); Direction = new Vect3D(0, 0, 0); U = 0; V = 0; }
protected Material(float kdiff, float kspec, float kamb, float refractIndex, float ktrans, float glossy, float shiness, Texture texture) { this.KDiff = kdiff; this.KSpec = kspec; this.KTrans = ktrans; this.KAmb = kamb; this.diffuseColor = RGBColor.White; this.specularColor = RGBColor.White; this.RefractIndex = refractIndex; this.Glossy = glossy; this.Absorptivity = 0.3f; this.Shiness = shiness; if (!texture.IsLoaded) { this.isTexturized = false; } else { this.texture = texture; this.isTexturized = true; } }
public MaterialData3DS() { this.ambient = RGBColor.Black; this.diffuse = RGBColor.Black; this.name = ""; this.textureName = ""; this.textureWeight = (float) 0.0; }
public static void Extract1Channel(RGB161616Image image, RGBColor plane, DoubleImage chan) { VisionLabPINVOKE.Extract1Channel__SWIG_74(RGB161616Image.getCPtr(image), (int)plane, DoubleImage.getCPtr(chan)); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); }
public ScenarioObjectPermutationStruct(BinaryReader binaryReader) { this.variantName = binaryReader.ReadStringID(); this.activeChangeColors = (ActiveChangeColors)binaryReader.ReadInt32(); this.primaryColor = binaryReader.ReadRGBColor(); this.secondaryColor = binaryReader.ReadRGBColor(); this.tertiaryColor = binaryReader.ReadRGBColor(); this.quaternaryColor = binaryReader.ReadRGBColor(); }
public void RGBColor() { var color = new RGBColor(0, 0.5, 0.445); Assert.AreEqual("RGB [R=0, G=0.5, B=0.45]", color.ToString()); }
public static string RGBColorToStr(RGBColor col) { string ret = VisionLabPINVOKE.RGBColorToStr((int)col); if (VisionLabPINVOKE.SWIGPendingException.Pending) throw VisionLabPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public DecoratorPlacementBlock(BinaryReader binaryReader) { this.internalData1 = binaryReader.ReadInt32(); this.compressedPosition = binaryReader.ReadInt32(); this.tintColor = binaryReader.ReadRGBColor(); this.lightmapColor = binaryReader.ReadRGBColor(); this.compressedLightDirection = binaryReader.ReadInt32(); this.compressedLight2Direction = binaryReader.ReadInt32(); }
public ScenarioCutsceneTitleBlock(BinaryReader binaryReader) { this.name = binaryReader.ReadStringID(); this.textBoundsOnScreen = binaryReader.ReadVector2(); this.justification = (Justification)binaryReader.ReadInt16(); this.font = (Font)binaryReader.ReadInt16(); this.textColor = binaryReader.ReadRGBColor(); this.shadowColor = binaryReader.ReadRGBColor(); this.fadeInTimeSeconds = binaryReader.ReadSingle(); this.upTimeSeconds = binaryReader.ReadSingle(); this.fadeOutTimeSeconds = binaryReader.ReadSingle(); this.paddingpadding = binaryReader.ReadBytes(2); }
public SpriteVerticesBlock(BinaryReader binaryReader) { this.position = binaryReader.ReadVector3(); this.offset = binaryReader.ReadVector3(); this.axis = binaryReader.ReadVector3(); this.texcoord = binaryReader.ReadVector2(); this.color = binaryReader.ReadRGBColor(); }
public DecalVerticesBlock(BinaryReader binaryReader) { this.position = binaryReader.ReadVector3(); this.texcoord0 = binaryReader.ReadVector2(); this.texcoord1 = binaryReader.ReadVector2(); this.color = binaryReader.ReadRGBColor(); }
/***************************************************************************************** The code below is based on http://www.developers.meethue.com/documentation/color-conversions-rgb-xy Converted to C# by Niels Laute *****************************************************************************************/ public static CGPoint CalculateXY(RGBColor color, string model) { //CGColorRef cgColor = [color CGColor]; //const CGFloat* components = CGColorGetComponents(cgColor); //long numberOfComponents = CGColorGetNumberOfComponents(cgColor); // Default to white double red = 1.0f; double green = 1.0f; double blue = 1.0f; //if (numberOfComponents == 4) //{ // Full color red = color.R; green = color.G; blue = color.B; //} //else if (numberOfComponents == 2) //{ // // Greyscale color // red = green = blue = color.A; //} // Apply gamma correction double r; double g; double b; if (red > 0.04045f) { r = (float)Math.Pow((red + 0.055f) / (1.0f + 0.055f), 2.4f); } else { r = red / 12.92f; } if (green > 0.04045f) { g = (float)Math.Pow((green + 0.055f) / (1.0f + 0.055f), 2.4f); } else { g = green / 12.92f; } if (blue > 0.04045f) { b = (float)Math.Pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f); } else { b = blue / 12.92f; } // Wide gamut conversion D65 double X = r * 0.664511f + g * 0.154324f + b * 0.162028f; double Y = r * 0.283881f + g * 0.668433f + b * 0.047685f; double Z = r * 0.000088f + g * 0.072310f + b * 0.986039f; double cx = 0.0f; if((X + Y + Z) != 0) cx = X / (X + Y + Z); double cy = 0.0f; if((X + Y + Z) != 0) cy = Y / (X + Y + Z); //Check if the given XY value is within the colourreach of our lamps. CGPoint xyPoint = new CGPoint(cx, cy); List<CGPoint> colorPoints = ColorPointsForModel(model); bool inReachOfLamps = CheckPointInLampsReach(xyPoint, colorPoints); if (!inReachOfLamps) { //It seems the colour is out of reach //let's find the closest colour we can produce with our lamp and send this XY value out. //Find the closest point on each line in the triangle. CGPoint pAB = GetClosestPointToPoints(colorPoints[0], colorPoints[1], xyPoint); CGPoint pAC = GetClosestPointToPoints(colorPoints[2], colorPoints[0], xyPoint); CGPoint pBC = GetClosestPointToPoints(colorPoints[1], colorPoints[2], xyPoint); //Get the distances per point and see which point is closer to our Point. float dAB = GetDistanceBetweenTwoPoints(xyPoint, pAB); float dAC = GetDistanceBetweenTwoPoints(xyPoint, pAC); float dBC = GetDistanceBetweenTwoPoints(xyPoint, pBC); float lowest = dAB; CGPoint closestPoint = pAB; if (dAC < lowest) { lowest = dAC; closestPoint = pAC; } if (dBC < lowest) { lowest = dBC; closestPoint = pBC; } //Change the xy value to a value which is within the reach of the lamp. cx = (float)closestPoint.x; cy = (float)closestPoint.y; } return new CGPoint(cx, cy); }
private static unsafe void BitmapToRGBColorMatrix(Bitmap img, ref RGBColor[,] textureMatrix) { using (img) { BitmapData imgData = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.ReadOnly, img.PixelFormat); byte bitsPerPixel = GetBitsPerPixel(imgData.PixelFormat); byte* scan0 = (byte*) imgData.Scan0.ToPointer(); for (int x = 0; x < imgData.Height; ++x) { for (int y = 0; y < imgData.Width; ++y) { byte* data = scan0 + x * imgData.Stride + y * bitsPerPixel / 8; textureMatrix[y, x] = new RGBColor(data[2], data[1], data[0]); textureMatrix[y, x].Normalize(); } } img.UnlockBits(imgData); } }
// Use this for initialization void Start() { selectedColor = new Texture2D(32,32); selectedColorStyle = new GUIStyle(); sheetData = new SpriteSheetData(); sheetData.Initialize(); SetPalettes(); canvas.material.mainTexture = sheetData.buffered; //NewCanvas(); //GUI Elements Console.Bind("spriteEdit", 0, 0, 250, 120); Window newWindow = new Window(); newWindow.Initialize("spriteEdit", 0, 0, 120, 25, Toolbar, Window.Align.TopLeft); GUIManager.windows.Add(newWindow); newWindow = new Window(); newWindow.Initialize("spriteEdit", 0, 0, 290, 90, Palette, Window.Align.BottomLeft); GUIManager.windows.Add(newWindow); newWindow = new Window(); newWindow.Initialize("spriteEdit", 0, 0, 138, 74, Swatches, Window.Align.Bottom); GUIManager.windows.Add(newWindow); mainColor = new RGBColor(); mainColor.SetColor(0,0,0); selectedColorStyle.normal.background = selectedColor; }
public StrongConnectedComponentInfo(KosarajuAlgorithm strongConnectedComponent, RGBColor[] vertexColors) { StrongConnectedComponent = strongConnectedComponent; VertexColors = vertexColors; }
private void GenStrongConnectedComponentColors() { StrongConnectedComponentColors = new RGBColor[StrongConnectedComponentGraph.StrongConnectedComponentCount]; for (int i = 0; i < StrongConnectedComponentGraph.StrongConnectedComponentCount; ++i) StrongConnectedComponentColors[i] = new RGBColor((byte)rnd.Next(25, 255), (byte)rnd.Next(25, 255), (byte)rnd.Next(25, 255)); }