public void Add(SColor _c) { r += _c.r; g += _c.g; b += _c.b; a += _c.a; }
private void Timer1_Tick(object sender, EventArgs e) { timer1.Stop(); timer1.Enabled = false; string sendString; SColor color = new SColor(0, 0, 0); if (manualToolStripMenuItem.Checked == true) { color.Red = (byte)(ulong)tbRed.Value; color.Green = (byte)(ulong)tbGreen.Value; color.Blue = (byte)(ulong)tbBlue.Value; } else { var rounded = Convert.ToInt32(cpuUsage); if (steps != null) { foreach (var item in steps) { if (rounded >= item.From && rounded <= item.To) { color.SetColor(item.Color); break; } } } } pbColorBox.BackColor = Color.FromArgb(color.Red, color.Green, color.Blue); sendString = $"{color.ToUlong()}"; if (port != null && port.IsOpen) { Console.Write(sendString); try { port.WriteLine(sendString); Console.WriteLine($"{ScolorToString(color)}=>({color.Red},{color.Green},{color.Blue})"); } catch (Exception exception) { Console.WriteLine("Exception :" + exception.Message); return; } } if (manualToolStripMenuItem.Checked == false) { timer1.Interval = 1000; timer1.Enabled = true; } else { timer1.Interval = 200; } }
private void ShootRay() { RaycastHit hit; if (Physics.Raycast(transform.position, cam.ScreenPointToRay(Input.mousePosition).direction, out hit, Mathf.Infinity)) { if (hit.transform.name == "Red") { GetComponent <SoundHandler>().PlaySound("bleep1"); color = SColor.Red; OnClickOnColor(color); } else if (hit.transform.name == "Green") { GetComponent <SoundHandler>().PlaySound("bleep2"); color = SColor.Green; OnClickOnColor(color); } else if (hit.transform.name == "Blue") { GetComponent <SoundHandler>().PlaySound("bleep3"); color = SColor.Blue; OnClickOnColor(color); } else if (hit.transform.name == "Yellow") { GetComponent <SoundHandler>().PlaySound("bleep4"); color = SColor.Yellow; OnClickOnColor(color); } } }
public void Display(SColor color) { switch (color) { case SColor.Red: GetComponent <SoundHandler>().PlaySound("bleep1"); StartCoroutine(DisplayAnimation(0)); break; case SColor.Green: GetComponent <SoundHandler>().PlaySound("bleep2"); StartCoroutine(DisplayAnimation(1)); break; case SColor.Blue: GetComponent <SoundHandler>().PlaySound("bleep3"); StartCoroutine(DisplayAnimation(2)); break; case SColor.Yellow: GetComponent <SoundHandler>().PlaySound("bleep4"); StartCoroutine(DisplayAnimation(3)); break; } }
public void Add(SColor c) { R += c.R; G += c.G; B += c.B; A += c.A; }
public void OnWindowChange(IBaseWindow window, NamedId inParamType, CBaseParam inNewParam) { Control pc; if (!_controls.TryGetValue(window.Id, out pc)) { return; } if (inParamType == SWindowParamDescr.Name.Id) { pc.Name = inNewParam.ToString(); } else if (inParamType == SWindowParamDescr.Indent.Id || inParamType == SWindowParamDescr.Shift.Id || inParamType == SWindowParamDescr.Size.Id) { Rect rect = window.GetRect(true); pc.Location = new Point((int)rect.left, (int)rect.top); pc.Size = new Size((int)rect.Width, (int)rect.Hight); } else if (inParamType == SWindowParamDescr.Color.Id) { SColor clr = inNewParam.ToColor(); pc.BackColor = Color.FromArgb(clr.a, clr.r, clr.g, clr.b); } else if (inParamType == WindowParams.Text.Id) { pc.Text = inNewParam.ToString(); } }
private void CheckIfWrong(SColor color) { if (color != crl.ColorPattern[currentGuess] || crl.ColorPattern.Count == 0) { GetComponent <ResetGame>().Die(); } }
public override bool scatter(Ray rayIn, ShadeRec record, ref SColor attenuation, ref Ray scattered) { Vector3D reflected = Reflect(rayIn.normalDirection, record.normal); scattered = new Ray(record.p, reflected + fuzz * GetRandomPointInUnitSphere(), rayIn.time); attenuation = texture.value(record.u, record.v, record.p); return((scattered.direction * record.normal) > 0); }
void StringColorToForm(string color) { ulong res = Convert.ToUInt32(color); var colorRet = new SColor(res); tbRed.Value = colorRet.Red; tbGreen.Value = colorRet.Green; tbBlue.Value = colorRet.Blue; }
//============================================================ // <T>创建色刷。</T> // // @parma color 颜色 // @return 色刷 //============================================================ public FDxSolidBrush CreateSolidBrush(SColor color) { FDxSolidBrush result = new FDxSolidBrush(); result.Device = this; result.Color.Assign(color); result.Setup(); return(result); }
private void SetPixel(int x, int y, SColor c32) { int i = width * 4 * y + x * 4; Changes[width * y + x]++; buff[i] += c32.R; buff[i + 1] += c32.G; buff[i + 2] += c32.B; buff[i + 3] += c32.A; }
public static Color Deserialize(this SColor _color) { Color returnVal = new Color { r = _color.r, g = _color.g, b = _color.b, a = _color.a }; return(returnVal); }
private void MagnifyingGlass_Click(object sender, EventArgs e) { SelectColor(MGlass.PixelColor); MGlass.Hide(); MGlass.UpdateTimer.Stop(); AColor.Hide(); SColor.Show(); lR.Show(); lG.Show(); lB.Show(); lH.Show(); bSelect.Show(); }
private void InputColor(SColor color) { if (!CreateRandomLights.enableInput) { return; } CheckIfWrong(color); displayColor.Display(color); CheckIfDone(); }
private void GridViewUpdateColorCells() { foreach (DataGridViewRow row in dataGridView1.Rows) { var cell = row.Cells[2]; var num = cell.Value; if (num != null) { var col = new SColor((ulong)num); cell.Style.BackColor = Color.FromArgb(col.Red, col.Green, col.Blue); } } }
private void bSelect_Click(object sender, EventArgs e) { lR.Hide(); lG.Hide(); lB.Hide(); lH.Hide(); SColor.Hide(); bSelect.Hide(); MGlass.Show(); AColor.Show(); MGlass.UpdateTimer.Start(); MGlass.MovingGlass.Show(); }
//============================================================ // <T>生成设计颜色。</T> // // @param color 颜色 // @return 颜色 //============================================================ public FUiColor BuildDesignColor(SColor color) { string code = color.ToValue().ToString(); FUiColor result = _designColors.Find(code); if (result == null) { result = new FUiColor(); result.Set(color.R, color.G, color.B, color.A); result.brush = _context.Device.CreateSolidBrush(result); _designColors.Set(code, result); } return(result); }
public void DrawRectangle(Position position, Size size, SColor color) { int y0 = position.y; int y1 = y0 + size.height; int x0 = position.x; int x1 = x0 + size.width; for (int y = y0; y < y1; y++) { for (int x = x0; x < x1; x++) { DrawPixel(x, y, color); } } }
public static SColor Serialize(this Color _color) { if (_color == null) { return(null); } SColor returnVal = new SColor { r = _color.r, g = _color.g, b = _color.b, a = _color.a }; return(returnVal); }
public void DrawPixel(int x, int y, SColor color) { if (x < 0 || y < 0 || x >= size.width || y >= size.height) { return; } if (constrainedPosition != null && constrainedSize != null) { if (x < constrainedPosition.x || y < constrainedPosition.y || x >= constrainedPosition.x + constrainedSize.width || y >= constrainedPosition.y + constrainedSize.height) { return; } } int index = y * size.width + x; pixels[index] = color.color; }
//============================================================ //// <T>获得预览层集合。</T> ////============================================================ //[Browsable(false)] //public FUiControlLayers PreviewLayers { // get { return _previewLayers; } //} //============================================================ // <T>加载设置信息</T> // // @param xconfig 设置信息 //============================================================ public override void OnLoadConfig(FXmlNode xconfig) { base.OnLoadConfig(xconfig); // 加载设计信息 if (xconfig.Contains("design_layers")) { _designLayers = xconfig.GetBoolean("design_layers"); } if (xconfig.Contains("design_back")) { _designBack = xconfig.GetBoolean("design_back"); } if (xconfig.Contains("design_back_color")) { SColor color = new SColor(); color.ParseHex(xconfig.Get("design_back_color")); _designBackColor = Color.FromArgb(color.A, color.R, color.G, color.B); } }
public void Save() { Color[] colours = swapper.GetColours(); SColor[] sColours = new SColor[colours.Length]; for (int i = 0; i < colours.Length; ++i) { sColours[i] = new SColor(colours[i]); } BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/charData.dat"); bf.Serialize(file, sColours); file.Close(); Debug.Log("Saved"); }
private void LinearScanner(object o) { ScannerConfig config = (ScannerConfig)o; for (int j = config.h - 1; j >= 0; j--) { for (int i = 0; i < config.w; i++) { SColor color = mode == Mode.Diffusing ? Diffusing(camera.CreateRay( (i + Random.Get()) * recip_width, (j + Random.Get()) * recip_height), world, 0) : NormalMap(camera.CreateRay( (i + Random.Get()) * recip_width, (j + Random.Get()) * recip_height), world); SetPixel(config.w - i - 1, config.h - j - 1, color); } } Form1.main.BeginInvoke(new Action(() => { Form1.main.ShowTips(); })); }
private SColor Diffusing(Ray ray, HitableList hitableList, int depth) { ShadeRec record = new ShadeRec(); if (hitableList.Hit(ray, 0.0001, double.MaxValue, ref record)) { Ray r = new Ray(Vector3D.zero, Vector3D.zero); SColor attenuation = SColor.black; SColor emitted = record.material.emitted(record.u, record.v, record.p); if (depth >= MAX_SCATTER_TIME || !record.material.scatter(ray, record, ref attenuation, ref r)) { return(emitted); } SColor clr = Diffusing(r, hitableList, depth + 1); return(new SColor(clr.R * attenuation.R, clr.G * attenuation.G, clr.B * attenuation.B) + emitted); } double t = 0.5 * ray.normalDirection.Y + 1.0; return(SkyColor ? (1 - t) * new SColor(2, 2, 2) + t * new SColor(0.5, 0.7, 1) : SColor.black); }
private void BackgroundColorExecuted(object sender, ExecutedRoutedEventArgs e) { EditorSetOptions?option = e.Parameter as EditorSetOptions?; if (!option.HasValue) { return; } switch (option.Value) { case EditorSetOptions.Default: Engine.Instance.SceneManager.BackgroundColor = SceneManager.DefaultBackgroundColor; break; case EditorSetOptions.Set: { ColorPickerControls.Dialogs.ColorPickerStandardDialog dialog = new ColorPickerControls.Dialogs.ColorPickerStandardDialog(); dialog.colorPickerFull.SelectedColorChanged += (s, param) => { Engine.Instance.SceneManager.BackgroundColor = param.Value.ToSColor(); }; SColor scolor = Engine.Instance.SceneManager.BackgroundColor; dialog.InitialColor = Color.FromArgb(scolor.A, scolor.R, scolor.G, scolor.B); dialog.Owner = ShellService.Instance.MainWindow; bool?dialogResult = dialog.ShowDialog(); if (dialogResult != null && (bool)dialogResult == true) { Engine.Instance.SceneManager.BackgroundColor = dialog.SelectedColor.ToSColor(); } else { Engine.Instance.SceneManager.BackgroundColor = dialog.InitialColor.ToSColor(); } } break; default: break; } }
private void ModelColorExecuted(object sender, ExecutedRoutedEventArgs e) { EditorSetOptions?option = e.Parameter as EditorSetOptions?; if (!option.HasValue) { return; } M2SceneNode node = ModelSceneService.Instance.MainM2SceneNode; switch (option.Value) { case EditorSetOptions.Set: ColorPickerControls.Dialogs.ColorPickerStandardDialog dialog = new ColorPickerControls.Dialogs.ColorPickerStandardDialog(); dialog.colorPickerFull.SelectedColorChanged += (s, param) => { node.ModelColor = param.Value.ToSColor(); }; SColor scolor = node.ModelColor; dialog.InitialColor = Color.FromArgb(scolor.A, scolor.R, scolor.G, scolor.B); dialog.Owner = ShellService.Instance.MainWindow; bool?dialogResult = dialog.ShowDialog(); if (dialogResult != null && (bool)dialogResult == true) { node.ModelColor = dialog.SelectedColor.ToSColor(); } else { node.ModelColor = dialog.InitialColor.ToSColor(); } break; case EditorSetOptions.Default: node.ModelColor = Colors.White.ToSColor(); break; } }
public DrawingInfo(SpriteBatch batch, Texture2D texture, SRectangle?sourceRectangle, Vector2 destination, SColor tint, Vector2 origin, float rotation, SpriteEffects effects, float depth) : this() { this.Texture = texture; this.SourceRectangle = sourceRectangle; this.Tint = tint; this.Batch = batch; this.Origin = origin; this.Rotation = rotation; this.Effects = effects; this.Depth = depth; SRectangle sourceBounds = this.SourceRectangle ?? this.Texture.Bounds; this.Destination = new SRectangle((int)destination.X, (int)destination.Y, sourceBounds.Width, sourceBounds.Height); }
public DrawingInfo(SpriteBatch batch, Texture2D texture, SRectangle?sourceRectangle, SRectangle destination, SColor tint, Vector2 origin, float rotation, SpriteEffects effects, float depth) : this() { this.Texture = texture; this.SourceRectangle = sourceRectangle; this.Destination = destination; this.Tint = tint; this.Batch = batch; this.Origin = origin; this.Rotation = rotation; this.Effects = effects; this.Depth = depth; }
public TintedSprite(ISprite sprite, SColor tint) { this.Sprite = sprite; this.Tint = tint; }
internal static unsafe void DrawTriangleLQ(int *imgptr, int stride, int color1, double x1, double y1, int color2, double x2, double y2, int color3, double x3, double y3) { unchecked { var point = stackalloc SPoint[3]; //02 34 51 // 1 2 3 + + + // 1 3 2 + + - // 2 1 3 - + + // 2 3 1 - + - // 3 1 2 + - // 3 2 1 - - if (y1 < y2) { if (y1 < y3) { point[0].Color = color1; point[0].X = (int)x1; point[0].Y = (int)y1; if (y2 < y3) { point[1].Color = color2; point[1].X = (int)x2; point[1].Y = (int)y2; point[2].Color = color3; point[2].X = (int)x3; point[2].Y = (int)y3; } else { point[1].Color = color3; point[1].X = (int)x3; point[1].Y = (int)y3; point[2].Color = color2; point[2].X = (int)x2; point[2].Y = (int)y2; } } else { point[0].Color = color3; point[0].X = (int)x3; point[0].Y = (int)y3; point[1].Color = color1; point[1].X = (int)x1; point[1].Y = (int)y1; point[2].Color = color2; point[2].X = (int)x2; point[2].Y = (int)y2; } } else if (y2 < y3) { point[0].Color = color2; point[0].X = (int)x2; point[0].Y = (int)y2; if (y1 < y3) { point[1].Color = color1; point[1].X = (int)x1; point[1].Y = (int)y1; point[2].Color = color3; point[2].X = (int)x3; point[2].Y = (int)y3; } else { point[1].Color = color3; point[1].X = (int)x3; point[1].Y = (int)y3; point[2].Color = color1; point[2].X = (int)x1; point[2].Y = (int)y1; } } else { point[0].Color = color3; point[0].X = (int)x3; point[0].Y = (int)y3; point[1].Color = color2; point[1].X = (int)x2; point[1].Y = (int)y2; point[2].Color = color1; point[2].X = (int)x1; point[2].Y = (int)y1; } float e1ydiff = (float)(point[2].Y - point[0].Y); if (e1ydiff == 0.0f) { return; } float e1xdiff = (float)(point[2].X - point[0].X); SColor e1colordiff = (point[2].Color - point[0].Color); int p = 1; do { float e2ydiff = (float)(point[p + 1].Y - point[p].Y); if (e2ydiff == 0.0f) { continue; } float e2xdiff = (float)(point[p + 1].X - point[p].X); SColor e2colordiff = (point[p + 1].Color - point[p].Color); float factor1 = (float)(point[p].Y - point[0].Y) / e1ydiff; float factorStep1 = 1.0f / e1ydiff; float factor2 = 0.0f; float factorStep2 = 1.0f / e2ydiff; var psrc = imgptr + point[p].Y * stride; for (int y = point[p].Y; y < point[p + 1].Y; y++) { int sX1 = point[0].X + (int)(e1xdiff * factor1); int sX2 = point[p].X + (int)(e2xdiff * factor2); SColor colordiff, sColor1; int xdiff = sX2 - sX1; if (xdiff != 0) { if (xdiff <= 0) { sX1 = sX2; sX2 = sX1 + (xdiff = -xdiff); sColor1 = point[p].Color + (e2colordiff * factor2); colordiff = point[0].Color + (e1colordiff * factor1) - sColor1; } else { sColor1 = point[0].Color + (e1colordiff * factor1); colordiff = point[p].Color + (e2colordiff * factor2) - sColor1; } float factor = 0.0f; float factorStep = 1.0f / (float)xdiff; psrc += sX1; do { *psrc = (sColor1 + (colordiff * factor)); ++psrc; factor += factorStep; } while (--xdiff != 0); psrc -= sX2; } psrc += stride; factor1 += factorStep1; factor2 += factorStep2; } } while (--p == 0); } }