private void SLVC(object sender, RoutedPropertyChangedEventArgs <double> e) { tb_hue.Text = sl_hue.Value.ToString(); tb_dark.Text = sl_dark.Value.ToString(); cells[8] = tb_hue.Text; cells[9] = tb_dark.Text; wpc.Background = new SolidColorBrush(ColorScale.ColorFromHSL(this.Hue(), 1, (1 - this.Dark()) > 0.5 ? 1 - this.Dark() : 0.5)); }
static MagicalAbility() { Icon = MJPModEntry.SHelper.Content.Load <Texture2D>("assets/icons.png"); for (float h = 0; h <= 1; h += 0.01f) { if (h * 100 < ColorMap.Length) { ColorMap[(int)Math.Floor(h * 100)] = ColorScale.ColorFromHSL(h, .7f, .7f); } } }
public static Tuple <Mesh, List <Line> > MakeFrame(Model model, List <double> displacements) { var points = new List <Box>(); var beams = new List <Line>(); var meshes = new List <Mesh>(); Mesh meshComb = new Mesh(); if (model is null | displacements is null) { return(new Tuple <Mesh, List <Line> >(meshComb, beams)); } foreach (var node in model.Nodes) { var size = 0.02; //1.0 / xSize; var bbox = new BoundingBox(-size, -size, -size, size, size, size); var box = new Box(bbox); box.Transform(Transform.Translation(node.Location.X, node.Location.Y, node.Location.Z)); var temp = new Mesh(); points.Add(box); } foreach (var bar in model.Elements) { var start = bar.Nodes[0].Location; var end = bar.Nodes[1].Location; var line = new Line(new Point3d(start.X, start.Y, start.Z), new Point3d(end.X, end.Y, end.Z)); beams.Add(line); } var maxdisp = displacements.Select(i => Math.Abs(i)).Max(); var scale = 0.33 / maxdisp; for (int i = 0; i < points.Count; i++) { var mesh = Mesh.CreateFromBox(points[i], 1, 1, 1); Color color = ColorScale.ColorFromHSL((0.33 - scale * Math.Abs(displacements[i])), 1.0, 0.5); Color[] colors = Enumerable.Repeat(color, 24).ToArray(); mesh.VertexColors.AppendColors(colors); meshes.Add(mesh.DuplicateMesh()); } meshComb.Append(meshes); return(new Tuple <Mesh, List <Line> >(meshComb, beams)); }
public static Bitmap BitmapFromHSL(Matrix <double> hsls, int subdivisions) { //USE BYTES INSTEAD?? Bitmap bitmap; Color[] colors = new Color[hsls.RowCount]; for (int i = 0; i < hsls.RowCount; i++) { colors[i] = ColorScale.ColorFromHSL(hsls[i, 0], hsls[i, 1], hsls[i, 2]); } var arrToBitmap = new Accord.Imaging.Converters.ArrayToImage(subdivisions, subdivisions); arrToBitmap.Convert(colors, out bitmap); //bitmap.Save(@"C:\Users\antmi\pictures\testing.png"); return(bitmap); }
public object Convert(object value, Type targetType, object parameter, string language) { // FIX NULL VALUES if (value == null) { return(null); } double val; if (!double.TryParse(value.ToString(), out val)) { return(null); } double hue = 0.375 * val * val + 5.94166303 * val + 4.383353333, saturation = 42, luminance = 60; Double.TryParse(parameter.ToString(), out luminance); if (val == 0) { if (luminance == 36) { return(Windows.UI.Xaml.Application.Current.Resources["DarkerGreyBorder"]); } else if (luminance == 90) { return(Windows.UI.Xaml.Application.Current.Resources["BGGGrey"]); } } if (val < 1 || val > 10) { return(null); } Color gradeColor = ColorScale.ColorFromHSL(hue, saturation, luminance); // hue(0-360), saturation(0-100), luminosity(0-100) return(new SolidColorBrush(gradeColor)); }
public void handle_init() { try { sl_dark.Value = this.Dark(); sl_hue.Value = this.Hue(); tb_dark.Text = cells[9]; tb_hue.Text = cells[8]; wpc.Background = new SolidColorBrush(ColorScale.ColorFromHSL(this.Hue(), 1, (1 - this.Dark()) > 0.5 ? 1 - this.Dark() : 0.5)); sl_hue.ValueChanged += SLVC; sl_dark.ValueChanged += SLVC; sl_dark.PreviewMouseLeftButtonUp += MLBU_Sync; sl_hue.PreviewMouseLeftButtonUp += MLBU_Sync; cmb.ItemsSource = win.mode_list; cmb.SelectedIndex = int.Parse(cells[4]); cmb.SelectionChanged += ModeSC; } catch (Exception) { return; } }