public static void EnableChams() { bool flag = !ESPOptions.ChamsEnabled; if (!flag) { Color32 color = ColorUtilities.getColor("_ChamsFriendVisible"); Color32 color2 = ColorUtilities.getColor("_ChamsFriendInvisible"); Color32 color3 = ColorUtilities.getColor("_ChamsEnemyVisible"); Color32 color4 = ColorUtilities.getColor("_ChamsEnemyInvisible"); foreach (SteamPlayer steamPlayer in Provider.clients.ToArray()) { Color32 front = FriendUtilities.IsFriendly(steamPlayer.player) ? color : color3; Color32 behind = FriendUtilities.IsFriendly(steamPlayer.player) ? color2 : color4; Player player = steamPlayer.player; bool flag2 = player == null || player == OptimizationVariables.MainPlayer || player.gameObject == null || player.life == null || player.life.isDead; if (!flag2) { GameObject gameObject = player.gameObject; ESPCoroutines.DoChamsGameObject(gameObject, front, behind); } } } }
protected override void DrawTopDown(MapGraphics graphics) { graphics.drawLayers[(int)MapGraphics.DrawLayers.FillBuffers].Add(() => { var data = GetData(); foreach (var dataPoint in data) { DrawIcon(graphics, graphics.view.mode == MapView.ViewMode.ThreeDimensional, dataPoint.x, dataPoint.y, dataPoint.z, dataPoint.angle, dataPoint.tex.Value, 1); } if (OutlineWidth != 0) { var color = ColorUtilities.ColorToVec4(OutlineColor, OpacityByte); for (int i = 0; i < data.Count - 1; i++) { graphics.lineRenderer.Add( new Vector3(data[i].x, data[i].y, data[i].z), new Vector3(data[i + 1].x, data[i + 1].y, data[i + 1].z), color, OutlineWidth); } } }); }
private static void OnHueValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Media.Color color, color1; Media.LinearGradientBrush lgb; HslSlider slider = d as HslSlider; if (slider.ColorScale == SliderScaleEnum.S) { lgb = new Media.LinearGradientBrush(); lgb.StartPoint = new Point(0.5, 1.0); lgb.EndPoint = new Point(0.5, 0.0); color = ColorUtilities.Hsl2MediaColor(slider.HueValue, 0.0, 0.5); color1 = ColorUtilities.Hsl2MediaColor(slider.HueValue, 1.0, 0.5); lgb.GradientStops.Add(new Media.GradientStop(color, 0.0)); lgb.GradientStops.Add(new Media.GradientStop(color1, 1.0)); if (slider.scale != null) { slider.scale.Background = lgb; } } }
public ColorWay(Color fg, Color bg) { Foreground = new ColorComp(fg); Background = new ColorComp(bg); if (Background.ContrastPen.Color.R == 0) { // light bg Bright = new ColorComp(ColorUtilities.Brighten(fg, -0.6)); // super high contrast High = interpolateToGray(fg, bg, 0.35); //closest to FG Medium = interpolateToGray(fg, bg, 0.70); Low = interpolateToGray(fg, bg, 0.85); VLow = interpolateToGray(fg, bg, 0.95); } else { // dark bg Bright = new ColorComp(ColorUtilities.Brighten(fg, 0.60)); High = interpolateToGray(fg, bg, 0.25);//closest to FG Medium = interpolateToGray(fg, bg, 0.60); Low = interpolateToGray(fg, bg, 0.75); VLow = interpolateToGray(fg, bg, 0.85); } }
private void CreateSpectrum() { _pickerBrush = new LinearGradientBrush(); _pickerBrush.StartPoint = new Point(0.5, 0); _pickerBrush.EndPoint = new Point(0.5, 1); _pickerBrush.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation; var colorsList = ColorUtilities.GenerateHsvSpectrum(); double stopIncrement = ( double )1 / (colorsList.Count - 1); int i; for (i = 0; i < colorsList.Count; i++) { _pickerBrush.GradientStops.Add(new GradientStop(colorsList[i], i * stopIncrement)); } _pickerBrush.GradientStops[i - 1].Offset = 1.0; if (_spectrumDisplay != null) { _spectrumDisplay.Fill = _pickerBrush; } }
protected override void DrawTopDown(MapGraphics graphics) { if (OutlineWidth == 0) { return; } graphics.drawLayers[(int)MapGraphics.DrawLayers.FillBuffers].Add(() => { bool isFirstVertex = false; Vector3 lastVertex = default(Vector3); foreach (var vert in GetVertices(graphics)) { var newVertex = vert; if (isFirstVertex) { graphics.lineRenderer.Add(lastVertex, newVertex, ColorUtilities.ColorToVec4(OutlineColor, OpacityByte), OutlineWidth); } isFirstVertex = !isFirstVertex; lastVertex = newVertex; } }); }
public override Brush GetColorDetailsBrush(HsvColor hsvColor) { GeometryDrawing geomDrawing1 = new GeometryDrawing(); geomDrawing1.Geometry = new RectangleGeometry(new Rect(0, 0, 100, 100)); geomDrawing1.Brush = ColorUtilities.GetHueBrash(hsvColor.S, 1.0); ((LinearGradientBrush)geomDrawing1.Brush).EndPoint = new Point(1, 0); GeometryDrawing geomDrawing2 = new GeometryDrawing(); geomDrawing2.Geometry = new RectangleGeometry(new Rect(0, 0, 100, 100)); geomDrawing2.Brush = new LinearGradientBrush(Colors.Black, Color.FromScRgb(0, 0, 0, 0), new Point(0.5, 1), new Point(0.5, 0)); DrawingGroup rootDrawingGroup = new DrawingGroup(); rootDrawingGroup.Children.Add(geomDrawing1); rootDrawingGroup.Children.Add(geomDrawing2); DrawingBrush br = new DrawingBrush(rootDrawingGroup); br.Freeze(); return(br); }
private static Color GetColor(string key, Color defaultValue) { var value = EditorPrefs.GetInt(key, (int)ColorUtilities.ToHex(defaultValue)); return(ColorUtilities.ToRGBA((uint)value)); }
public SizingPanelViewModel(EncodingWindowViewModel encodingWindowViewModel) : base(encodingWindowViewModel) { this.AutomaticChange = true; this.RotationChoices = new List <RotationViewModel> { new RotationViewModel { Rotation = VCPictureRotation.None, Display = CommonRes.None, Image = "/Icons/Empty.png", ShowImage = false }, new RotationViewModel { Rotation = VCPictureRotation.Clockwise90, Display = EncodingRes.Rotation_Clockwise90, Image = "/Icons/rotate_90_cw.png" }, new RotationViewModel { Rotation = VCPictureRotation.Clockwise270, Display = EncodingRes.Rotation_Counterclockwise90, Image = "/Icons/rotate_90_ccw.png" }, new RotationViewModel { Rotation = VCPictureRotation.Clockwise180, Display = EncodingRes.Rotation_180, Image = "/Icons/rotate_180.png" } }; this.SizingModeChoices = new List <ComboChoice <VCSizingMode> > { new ComboChoice <VCSizingMode>(VCSizingMode.Automatic, CommonRes.Automatic), new ComboChoice <VCSizingMode>(VCSizingMode.Manual, EncodingRes.SizingModeManual), }; this.ScalingModeChoices = new List <ComboChoice <VCScalingMode> > { new ComboChoice <VCScalingMode>(VCScalingMode.DownscaleOnly, EncodingRes.ScalingMode_DownscaleOnly), new ComboChoice <VCScalingMode>(VCScalingMode.UpscaleFill, EncodingRes.ScalingMode_Fill), new ComboChoice <VCScalingMode>(VCScalingMode.Upscale2X, string.Format(EncodingRes.UpscaleMaxFormat, 2)), new ComboChoice <VCScalingMode>(VCScalingMode.Upscale3X, string.Format(EncodingRes.UpscaleMaxFormat, 3)), new ComboChoice <VCScalingMode>(VCScalingMode.Upscale4X, string.Format(EncodingRes.UpscaleMaxFormat, 4)), }; this.PaddingModeChoices = new List <ComboChoice <VCPaddingMode> > { new ComboChoice <VCPaddingMode>(VCPaddingMode.None, CommonRes.None), new ComboChoice <VCPaddingMode>(VCPaddingMode.Fill, EncodingRes.PaddingMode_Fill), new ComboChoice <VCPaddingMode>(VCPaddingMode.Width, EncodingRes.PaddingMode_Width), new ComboChoice <VCPaddingMode>(VCPaddingMode.Height, EncodingRes.PaddingMode_Height), new ComboChoice <VCPaddingMode>(VCPaddingMode.Custom, CommonRes.Custom), }; this.RegisterProfileProperties(); // WidthLabel this.WhenAnyValue(x => x.SizingMode, x => x.PaddingMode, x => x.ScalingMode, (sizingMode, paddingMode, scalingMode) => { if (sizingMode == VCSizingMode.Manual) { return(EncodingRes.WidthLabel); } switch (paddingMode) { case VCPaddingMode.Fill: case VCPaddingMode.Width: return(EncodingRes.WidthLabel); case VCPaddingMode.Height: return(EncodingRes.MaxWidthLabel); case VCPaddingMode.None: case VCPaddingMode.Custom: switch (scalingMode) { case VCScalingMode.UpscaleFill: return(EncodingRes.TargetWidthLabel); default: return(EncodingRes.MaxWidthLabel); } } return(string.Empty); }).ToProperty(this, x => x.WidthLabel, out this.widthLabel); // HeightLabel this.WhenAnyValue(x => x.SizingMode, x => x.PaddingMode, x => x.ScalingMode, (sizingMode, paddingMode, scalingMode) => { if (sizingMode == VCSizingMode.Manual) { return(EncodingRes.HeightLabel); } switch (paddingMode) { case VCPaddingMode.Fill: case VCPaddingMode.Height: return(EncodingRes.HeightLabel); case VCPaddingMode.Width: return(EncodingRes.MaxHeightLabel); case VCPaddingMode.None: case VCPaddingMode.Custom: switch (scalingMode) { case VCScalingMode.UpscaleFill: return(EncodingRes.TargetHeightLabel); default: return(EncodingRes.MaxHeightLabel); } } return(string.Empty); }).ToProperty(this, x => x.HeightLabel, out this.heightLabel); // AllowEmptyResolution this.WhenAnyValue(x => x.SizingMode, x => x.PaddingMode, x => x.ScalingMode, (sizingMode, paddingMode, scalingMode) => { if (sizingMode == VCSizingMode.Manual) { return(false); } switch (paddingMode) { case VCPaddingMode.None: case VCPaddingMode.Custom: return(scalingMode != VCScalingMode.UpscaleFill);; default: return(false); } }).ToProperty(this, x => x.AllowEmptyResolution, out this.allowEmptyResolution); // InputPreview this.MainViewModel.WhenAnyValue(x => x.SelectedTitle).Select(selectedTitle => { return(ResolutionUtilities.GetResolutionInfoLines(selectedTitle?.Title)); }).ToProperty(this, x => x.InputPreview, out this.inputPreview); // OutputPreview this.outputSizeService.WhenAnyValue(x => x.Size).Select(size => { var previewLines = new List <InfoLineViewModel>(); if (size == null) { return(previewLines); } string outputStorageResolutionString = size.OutputWidth + " x " + size.OutputHeight; if (size.Par.Num == size.Par.Den) { previewLines.Add(new InfoLineViewModel(EncodingRes.ResolutionLabel, outputStorageResolutionString)); } else { previewLines.Add(new InfoLineViewModel(EncodingRes.StorageResolutionLabel, outputStorageResolutionString)); previewLines.Add(new InfoLineViewModel(EncodingRes.PixelAspectRatioLabel, ResolutionUtilities.CreateParDisplayString(size.Par.Num, size.Par.Den))); string displayResolutionString = Math.Round(size.OutputWidth * (((double)size.Par.Num) / size.Par.Den)) + " x " + size.OutputHeight; previewLines.Add(new InfoLineViewModel(EncodingRes.DisplayResolutionLabel, displayResolutionString)); } return(previewLines); }).ToProperty(this, x => x.OutputPreview, out this.outputPreview); // PadColorEnabled this.WhenAnyValue(x => x.PaddingMode, paddingMode => { return(paddingMode != VCPaddingMode.None); }).ToProperty(this, x => x.PadColorEnabled, out this.padColorEnabled); // PadBrush this.WhenAnyValue(x => x.Profile.PadColor) .Select(padColor => { return(new SolidColorBrush(ColorUtilities.ToWindowsColor(this.Profile.PadColor))); }).ToProperty(this, x => x.PadBrush, out this.padBrush); // CroppingUIEnabled this.WhenAnyValue(x => x.CroppingType, croppingType => { return(croppingType == VCCroppingType.Custom); }).ToProperty(this, x => x.CroppingUIEnabled, out this.croppingUIEnabled); // Update the underlying profile when our local Crop properties change. This only applies for // CroppingType.Custom this.WhenAnyValue(x => x.CropTop) .Skip(1) .Subscribe(cropTop => { this.UpdateProfileProperty( () => this.Profile.Cropping, nameof(this.Profile.Cropping.Top), nameof(this.CropTop), cropTop, raisePropertyChanged: false); }); this.WhenAnyValue(x => x.CropBottom) .Skip(1) .Subscribe(cropBottom => { this.UpdateProfileProperty( () => this.Profile.Cropping, nameof(this.Profile.Cropping.Bottom), nameof(this.CropBottom), cropBottom, raisePropertyChanged: false); }); this.WhenAnyValue(x => x.CropLeft) .Skip(1) .Subscribe(cropLeft => { this.UpdateProfileProperty( () => this.Profile.Cropping, nameof(this.Profile.Cropping.Left), nameof(this.CropLeft), cropLeft, raisePropertyChanged: false); }); this.WhenAnyValue(x => x.CropRight) .Skip(1) .Subscribe(cropRight => { this.UpdateProfileProperty( () => this.Profile.Cropping, nameof(this.Profile.Cropping.Right), nameof(this.CropRight), cropRight, raisePropertyChanged: false); }); // Auto-fill the cropping properties when type is Auto or None this.WhenAnyValue( x => x.CroppingType, x => x.MainViewModel.SelectedTitle, (croppingType, selectedTitle) => { return(new { croppingType, selectedTitle }); }) .Subscribe(x => { bool oldAutoValue = this.AutomaticChange; if (x.croppingType == VCCroppingType.None) { this.AutomaticChange = true; this.CropTop = 0; this.CropBottom = 0; this.CropLeft = 0; this.CropRight = 0; } else if (x.croppingType == VCCroppingType.Automatic) { this.AutomaticChange = true; if (x.selectedTitle == null) { this.CropTop = 0; this.CropBottom = 0; this.CropLeft = 0; this.CropRight = 0; } else { this.CropTop = x.selectedTitle.Crop[0]; this.CropBottom = x.selectedTitle.Crop[1]; this.CropLeft = x.selectedTitle.Crop[2]; this.CropRight = x.selectedTitle.Crop[3]; } } this.AutomaticChange = oldAutoValue; }); // When the preset changes, update the local crop values for Custom. this.PresetsService.WhenAnyValue(x => x.SelectedPreset.Preset.EncodingProfile) .Subscribe(_ => { if (this.PresetsService.SelectedPreset.Preset.EncodingProfile.CroppingType == VCCroppingType.Custom) { bool oldAutoValue = this.AutomaticChange; this.AutomaticChange = true; var cropping = this.PresetsService.SelectedPreset.Preset.EncodingProfile.Cropping; this.CropLeft = cropping.Left; this.CropTop = cropping.Top; this.CropRight = cropping.Right; this.CropBottom = cropping.Bottom; this.AutomaticChange = oldAutoValue; } }); // PaddingUIEnabled this.WhenAnyValue(x => x.SizingMode, x => x.PaddingMode, (sizingMode, paddingMode) => { if (sizingMode == VCSizingMode.Manual) { return(true); } return(paddingMode == VCPaddingMode.Custom); }).ToProperty(this, x => x.PaddingUIEnabled, out this.paddingUIEnabled); // Update the underlying profile when our local Pad properties change. this.WhenAnyValue(x => x.PadTop) .Skip(1) .Subscribe(padTop => { this.UpdateProfileProperty( () => this.Profile.Padding, nameof(this.Profile.Padding.Top), nameof(this.PadTop), padTop, raisePropertyChanged: false); }); this.WhenAnyValue(x => x.PadBottom) .Skip(1) .Subscribe(padBottom => { this.UpdateProfileProperty( () => this.Profile.Padding, nameof(this.Profile.Padding.Bottom), nameof(this.PadBottom), padBottom, raisePropertyChanged: false); }); this.WhenAnyValue(x => x.PadLeft) .Skip(1) .Subscribe(padLeft => { this.UpdateProfileProperty( () => this.Profile.Padding, nameof(this.Profile.Padding.Left), nameof(this.PadLeft), padLeft, raisePropertyChanged: false); }); this.WhenAnyValue(x => x.PadRight) .Skip(1) .Subscribe(padRight => { this.UpdateProfileProperty( () => this.Profile.Padding, nameof(this.Profile.Padding.Right), nameof(this.PadRight), padRight, raisePropertyChanged: false); }); // Auto-fill the padding properties when UI is disabled this.WhenAnyValue( x => x.SizingMode, x => x.ScalingMode, x => x.PaddingMode, x => x.Width, x => x.Height, x => x.MainViewModel.SelectedTitle, (sizingMode, scalingMode, paddingMode, width, height, selectedTitle) => { return(new { sizingMode, scalingMode, paddingMode, width, height, selectedTitle }); }) .Subscribe(x => { bool oldAutoValue = this.AutomaticChange; if (x.sizingMode == VCSizingMode.Automatic && x.paddingMode == VCPaddingMode.None) { this.AutomaticChange = true; this.PadTop = 0; this.PadBottom = 0; this.PadLeft = 0; this.PadRight = 0; } else if (x.sizingMode == VCSizingMode.Automatic && x.paddingMode != VCPaddingMode.Custom) { if (x.selectedTitle == null) { this.PadTop = 0; this.PadBottom = 0; this.PadLeft = 0; this.PadRight = 0; } else { // Calculate the correct padding from input variables OutputSizeInfo outputSize = JsonEncodeFactory.GetOutputSize(this.Profile, x.selectedTitle.Title); this.PadTop = outputSize.Padding.Top; this.PadBottom = outputSize.Padding.Bottom; this.PadLeft = outputSize.Padding.Left; this.PadRight = outputSize.Padding.Right; } } this.AutomaticChange = oldAutoValue; }); // When the preset changes, update the local pad values. this.PresetsService.WhenAnyValue(x => x.SelectedPreset.Preset.EncodingProfile) .Subscribe(_ => { VCProfile profile = this.PresetsService.SelectedPreset.Preset.EncodingProfile; if (profile.SizingMode == VCSizingMode.Manual || profile.PaddingMode == VCPaddingMode.Custom) { bool oldAutoValue = this.AutomaticChange; this.AutomaticChange = true; var padding = profile.Padding; this.PadLeft = padding.Left; this.PadTop = padding.Top; this.PadRight = padding.Right; this.PadBottom = padding.Bottom; this.AutomaticChange = oldAutoValue; } }); this.AutomaticChange = false; }
// Add material with color replacement shader, and generate color replacement texture private Material GetMaterial(Character character) { // this 256x1 texture is transparent. Each pixel represents the red color value to replace. // if pixel 10 is not transparent, every color with r=10 will be replaced by the color of the pixel Texture2D colorSwapTex = new Texture2D(256, 1, TextureFormat.RGBA32, false, false); colorSwapTex.filterMode = FilterMode.Point; // Reset texture for (int i = 0; i < colorSwapTex.width; ++i) { colorSwapTex.SetPixel(i, 0, new Color(0.0f, 0.0f, 0.0f, 0.0f)); } colorSwapTex.Apply(); // Define the swapping colors. Add white to highlights and black to shadows Color newUniformStripeColorLight = Color.Lerp(character.GetCharacterColor(), ColorUtilities.ColorFromIntRGB(255, 255, 255), 0.5f); Color newUniformStripeColorVeryLight = Color.Lerp(newUniformStripeColorLight, ColorUtilities.ColorFromIntRGB(255, 255, 255), 0.5f); Color newUniformStripeColorDark = Color.Lerp(character.GetCharacterColor(), ColorUtilities.ColorFromIntRGB(0, 0, 0), 0.5f); Color newUniformStripeColorVeryDark = Color.Lerp(newUniformStripeColorDark, ColorUtilities.ColorFromIntRGB(0, 0, 0), 0.5f); Color newSkinColor = character.GetCharacterSkinColor(); Color newSkinColorDark = Color.Lerp(newSkinColor, ColorUtilities.ColorFromIntRGB(0, 0, 0), 0.2f); Color newSkinColorVeryDark = Color.Lerp(newSkinColorDark, ColorUtilities.ColorFromIntRGB(0, 0, 0), 0.5f); Color newUniformColor = character.GetCharacterUniformColor(); Color newUniformColorLight = Color.Lerp(newUniformColor, ColorUtilities.ColorFromIntRGB(255, 255, 255), 0.2f); Color newUniformColorVeryLight = Color.Lerp(newUniformColorLight, ColorUtilities.ColorFromIntRGB(255, 255, 255), 0.5f); Color newUniformColorDark = Color.Lerp(newUniformColor, ColorUtilities.ColorFromIntRGB(0, 0, 0), 0.2f); Color newUniformColorVeryDark = Color.Lerp(newUniformColorDark, ColorUtilities.ColorFromIntRGB(0, 0, 0), 0.5f); // add the colors to the texture // TODO: Do something similar for HAIRCOLOR, when we have a character with visible hair colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMCOLOR, newUniformColor); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMCOLORLIGHT, newUniformColorLight); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMCOLORVERYLIGHT, newUniformColorVeryLight); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMCOLORDARK, newUniformColorDark); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMCOLORVERYDARK, newUniformColorVeryDark); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMSTRIPECOLOR, character.GetCharacterColor()); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMSTRIPECOLORLIGHT, newUniformStripeColorLight); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMSTRIPECOLORVERYLIGHT, newUniformStripeColorVeryLight); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMSTRIPECOLORDARK, newUniformStripeColorDark); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.UNIFORMSTRIPECOLOVVERYRDARK, newUniformStripeColorVeryDark); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.SKINCOLOR, newSkinColor); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.SKINCOLORDARK, newSkinColorDark); colorSwapTex = SwapColor(colorSwapTex, SpriteSwapRedColor.SKINCOLORVERYDARK, newSkinColorVeryDark); colorSwapTex.Apply(); // load material and shader Material swapMaterial = new Material(Resources.Load <Material>("Shaders/ColorSwap")); Shader swapShader = Resources.Load <Shader>("Shaders/Sprites-ColorSwap"); swapMaterial.shader = swapShader; swapMaterial.SetTexture("_SwapTex", colorSwapTex); return(swapMaterial); }
private string GenerateHtml() { var linkTransform = @"<script type=""text/javascript""> for (var i = 0; i < document.links.length; i++) { document.links[i].onclick = function() { window.external.notify('LaunchLink: ' + this.href); return false; } }</script>"; var head = @"<!DOCTYPE html> <head> <style type=""text/css""> body { margin: 0; padding: 0; font-family: 'Segoe UI'; -ms-font-feature-settings: 'ss01' 1; font-size: 11pt; background-color: " + ColorUtilities.ToHex(Background) + @"; } </style> <meta name=""viewport"" content=""initial-scale=1, maximum-scale=1, user-scalable=0""/>" + "<script type=\"text/javascript\">document.documentElement.style.msScrollTranslation = 'vertical-to-horizontal';</script>" + "</head>"; if (string.IsNullOrEmpty(headerHtml)) { return(head + @"<html>" + "<body style='margin-left:-16px;margin-top:0px;'>" + "<div style='position: absolute; column-width: " + ColumnWidth + "px; column-fill: auto; " + //"column-rule-width: " + RuleWidth + "px; " + "height:" + (_webView.ActualHeight - Padding.Bottom) + "px; " + "color:" + ColorUtilities.ToHex(Foreground) + "; margin-left:" + Padding.Left + "px; " + "margin-right:" + Padding.Right + "px'>" + "<div style='margin-right:" + RuleWidth + "px'" + bodyHtml + "</div>" + "<div style='height:" + _webView.ActualHeight + "px'> </div>" + // <= used to have margin right => find better solution "</div>" + "</body>" + (LaunchExternalBrowser ? linkTransform : "") + "</html>"); } return(head + "<html>" + "<body style='margin-left:-16px;margin-top:0px;'>" + "<table>" + "<td width='" + HeaderWidth + "' style='width:" + HeaderWidth + "px'>" + "<div style='margin-left:" + Padding.Left + "px'>" + headerHtml + "</div>" + "</td>" + "<td>" + "<div style='position: absolute; column-width: " + ColumnWidth + "px; top:" + Padding.Top + "px; column-fill: auto; " + //"column-rule-width: " + RuleWidth + "px; " + "height:" + (_webView.ActualHeight - Padding.Bottom - Padding.Top) + "px; " + "color:" + ColorUtilities.ToHex(Foreground) + "; " + "margin-left:" + RuleWidth + "px'>" + "<div style='margin-right:" + RuleWidth + "px; " + "'>" + bodyHtml + "</div>" + "</div>" + "</td>" + "</table>" + "</body>" + (LaunchExternalBrowser ? linkTransform : "") + "</html>"); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (_colorShadingCanvas != null) { _colorShadingCanvas.MouseLeftButtonDown -= ColorShadingCanvas_MouseLeftButtonDown; _colorShadingCanvas.MouseLeftButtonUp -= ColorShadingCanvas_MouseLeftButtonUp; _colorShadingCanvas.MouseMove -= ColorShadingCanvas_MouseMove; _colorShadingCanvas.SizeChanged -= ColorShadingCanvas_SizeChanged; _colorShadingCanvas.Loaded -= _colorShadingCanvas_Loaded; } _colorShadingCanvas = GetTemplateChild(PART_ColorShadingCanvas) as Canvas; if (_colorShadingCanvas != null) { _colorShadingCanvas.MouseLeftButtonDown += ColorShadingCanvas_MouseLeftButtonDown; _colorShadingCanvas.MouseLeftButtonUp += ColorShadingCanvas_MouseLeftButtonUp; _colorShadingCanvas.MouseMove += ColorShadingCanvas_MouseMove; _colorShadingCanvas.SizeChanged += ColorShadingCanvas_SizeChanged; _colorShadingCanvas.Loaded += _colorShadingCanvas_Loaded; } _colorShadeSelector = GetTemplateChild(PART_ColorShadeSelector) as Canvas; if (_colorShadeSelector != null) { _colorShadeSelector.RenderTransform = _colorShadeSelectorTransform; } if (_spectrumSlider != null) { _spectrumSlider.ValueChanged -= SpectrumSlider_ValueChanged; } _spectrumSlider = GetTemplateChild(PART_SpectrumSlider) as ColorSpectrumSlider; if (_spectrumSlider != null) { _spectrumSlider.ValueChanged += SpectrumSlider_ValueChanged; } if (_hexadecimalTextBox != null) { _hexadecimalTextBox.LostFocus -= new RoutedEventHandler(HexadecimalTextBox_LostFocus); } _hexadecimalTextBox = GetTemplateChild(PART_HexadecimalTextBox) as TextBox; if (_hexadecimalTextBox != null) { _hexadecimalTextBox.LostFocus += new RoutedEventHandler(HexadecimalTextBox_LostFocus); } UpdateRGBValues(SelectedColor); UpdateColorShadeSelectorPosition(SelectedColor); // When changing theme, HexadecimalString needs to be set since it is not binded. SetHexadecimalTextBoxTextProperty(ColorUtilities.GetFormatedColorString(SelectedColor, UsingAlphaChannel)); }
private void RefreshPreviews() { this.originalScanInstance = this.ScanInstance; this.job = this.mainViewModel.EncodeJob; OutputSizeInfo newOutputSizeInfo = this.outputSizeService.Size; int width = newOutputSizeInfo.OutputWidth; int height = newOutputSizeInfo.OutputHeight; int parWidth = newOutputSizeInfo.Par.Num; int parHeight = newOutputSizeInfo.Par.Den; if (parWidth <= 0 || parHeight <= 0) { this.HasPreview = false; this.Title = PreviewRes.NoVideoSourceTitle; Ioc.Get <IAppLogger>().LogError("HandBrake returned a negative pixel aspect ratio. Cannot show preview."); return; } if (width < 100 || height < 100) { this.HasPreview = false; this.UpdateTitle(newOutputSizeInfo); return; } this.PreviewDisplayHeight = height; this.PreviewDisplayWidth = width * ((double)parWidth / parHeight); this.OutputSizeInfo = newOutputSizeInfo; var profile = this.PresetsService.SelectedPreset.Preset.EncodingProfile; this.PadColor = ColorUtilities.ToWindowsColor(profile.PadColor); // Update the number of previews. this.previewCount = this.ScanInstance.PreviewCount; if (this.selectedPreview >= this.previewCount) { this.selectedPreview = this.previewCount - 1; this.RaisePropertyChanged(nameof(this.SelectedPreview)); } this.RaisePropertyChanged(nameof(this.PreviewCount)); this.HasPreview = true; lock (this.imageSync) { this.previewImageCache = new BitmapSource[this.previewCount]; updateVersion++; // Clear main work queue. this.previewImageWorkQueue.Clear(); this.imageFileCacheFolder = Path.Combine( Utilities.ImageCacheFolder, Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture), updateVersion.ToString(CultureInfo.InvariantCulture)); if (!Directory.Exists(this.imageFileCacheFolder)) { Directory.CreateDirectory(this.imageFileCacheFolder); } // Clear old images out of the file cache. this.ClearImageFileCache(); this.imageFileSync = new List <object>(this.previewCount); for (int i = 0; i < this.previewCount; i++) { this.imageFileSync.Add(new object()); } this.BeginBackgroundImageLoad(); this.View?.RefreshImageSize(); } this.UpdateTitle(newOutputSizeInfo); }
private void ReadXml_Characters(XmlReader reader) { if (reader.ReadToDescendant("Character")) { do { Character character; int x = int.Parse(reader.GetAttribute("X")); int y = int.Parse(reader.GetAttribute("Y")); int z = int.Parse(reader.GetAttribute("Z")); if (reader.GetAttribute("r") != null) { Color color = ColorUtilities.ParseColorFromString(reader.GetAttribute("r"), reader.GetAttribute("g"), reader.GetAttribute("b")); Color colorUni = ColorUtilities.ParseColorFromString(reader.GetAttribute("rUni"), reader.GetAttribute("gUni"), reader.GetAttribute("bUni")); Color colorSkin = ColorUtilities.ParseColorFromString(reader.GetAttribute("rSkin"), reader.GetAttribute("gSkin"), reader.GetAttribute("bSkin")); character = CreateCharacter(tiles[x, y, z], color, colorUni, colorSkin); } else { character = CreateCharacter(tiles[x, y, z]); } character.name = reader.GetAttribute("name"); character.ReadXml(reader); // Read the children elements. // TODO: This should either not be XML, or use XmlSerializer. while (reader.Read()) { // Read until the end of the character. if (reader.NodeType == XmlNodeType.EndElement) { break; } switch (reader.Name) { case "Stats": character.ReadStatsFromSave(reader); break; case "Inventories": if (reader.ReadToDescendant("Inventory")) { do { // Create our inventory from the file Inventory inv = new Inventory( reader.GetAttribute("objectType"), int.Parse(reader.GetAttribute("maxStackSize")), int.Parse(reader.GetAttribute("stackSize"))); inventoryManager.PlaceInventory(character, inv); }while (reader.ReadToNextSibling("Inventory")); // One more read to step out of Inventories, so ReadToNextSibling will find sibling Character reader.Read(); } break; } } }while (reader.ReadToNextSibling("Character")); } }
private void OnVariableClick() { this.Focus(); bool isCtrlKeyHeld = KeyboardUtilities.IsCtrlHeld(); bool isShiftKeyHeld = KeyboardUtilities.IsShiftHeld(); bool isAltKeyHeld = KeyboardUtilities.IsAltHeld(); bool isFKeyHeld = Keyboard.IsKeyDown(Key.F); bool isHKeyHeld = Keyboard.IsKeyDown(Key.H); bool isLKeyHeld = Keyboard.IsKeyDown(Key.L); bool isDKeyHeld = Keyboard.IsKeyDown(Key.D); bool isRKeyHeld = Keyboard.IsKeyDown(Key.R); bool isCKeyHeld = Keyboard.IsKeyDown(Key.C); bool isBKeyHeld = Keyboard.IsKeyDown(Key.B); bool isQKeyHeld = Keyboard.IsKeyDown(Key.Q); bool isOKeyHeld = Keyboard.IsKeyDown(Key.O); bool isTKeyHeld = Keyboard.IsKeyDown(Key.T); bool isMKeyHeld = Keyboard.IsKeyDown(Key.M); bool isNKeyHeld = Keyboard.IsKeyDown(Key.N); bool isPKeyHeld = Keyboard.IsKeyDown(Key.P); bool isXKeyHeld = Keyboard.IsKeyDown(Key.X); bool isSKeyHeld = Keyboard.IsKeyDown(Key.S); bool isDeletishKeyHeld = KeyboardUtilities.IsDeletishKeyHeld(); bool isBacktickHeld = Keyboard.IsKeyDown(Key.OemTilde); bool isZHeld = Keyboard.IsKeyDown(Key.Z); bool isMinusHeld = Keyboard.IsKeyDown(Key.OemMinus); bool isPlusHeld = Keyboard.IsKeyDown(Key.OemPlus); bool isNumberHeld = KeyboardUtilities.IsNumberHeld(); if (isShiftKeyHeld && isNumberHeld) { _watchVariablePanel.UnselectAllVariables(); BaseColor = ColorUtilities.GetColorForVariable(); } //else if (isSKeyHeld) //{ // _watchVariablePanel.UnselectAllVariables(); // AddToTab(Config.CustomManager); //} //else if (isTKeyHeld) //{ // _watchVariablePanel.UnselectAllVariables(); // AddToTab(Config.TasManager); //} //else if (isMKeyHeld) //{ // _watchVariablePanel.UnselectAllVariables(); // AddToTab(Config.MemoryManager); //} else if (isNKeyHeld) { _watchVariablePanel.UnselectAllVariables(); WatchVarWrapper.ViewInMemoryTab(); } else if (isFKeyHeld) { _watchVariablePanel.UnselectAllVariables(); ToggleFixedAddress(); } else if (isHKeyHeld) { _watchVariablePanel.UnselectAllVariables(); ToggleHighlighted(); } else if (isNumberHeld) { _watchVariablePanel.UnselectAllVariables(); Color?color = ColorUtilities.GetColorForHighlight(); ToggleHighlighted(color); } else if (isLKeyHeld) { _watchVariablePanel.UnselectAllVariables(); WatchVarWrapper.ToggleLocked(null, FixedAddressListGetter()); } else if (isDKeyHeld) { _watchVariablePanel.UnselectAllVariables(); WatchVarWrapper.ToggleDisplayAsHex(); } else if (isRKeyHeld) { _watchVariablePanel.UnselectAllVariables(); RenameMode = true; } else if (isCKeyHeld) { _watchVariablePanel.UnselectAllVariables(); WatchVarWrapper.ShowControllerForm(); } else if (isBKeyHeld) { _watchVariablePanel.UnselectAllVariables(); WatchVarWrapper.ShowBitForm(); } else if (isDeletishKeyHeld) { _watchVariablePanel.UnselectAllVariables(); RemoveFromPanel(); } else if (isXKeyHeld) { _watchVariablePanel.UnselectAllVariables(); NotifyPanelOfReodering(); } else if (isBacktickHeld) { _watchVariablePanel.UnselectAllVariables(); AddToVarHackTab(); } else if (isZHeld) { _watchVariablePanel.UnselectAllVariables(); SetValue(0); } else if (isMinusHeld) { _watchVariablePanel.UnselectAllVariables(); AddValue(1, false); } else if (isPlusHeld) { _watchVariablePanel.UnselectAllVariables(); AddValue(1, true); } else if (isQKeyHeld) { _watchVariablePanel.UnselectAllVariables(); Color?newColor = ColorUtilities.GetColorFromDialog(BaseColor); if (newColor.HasValue) { BaseColor = newColor.Value; ColorUtilities.LastCustomColor = newColor.Value; } } else if (isOKeyHeld) { _watchVariablePanel.UnselectAllVariables(); BaseColor = ColorUtilities.LastCustomColor; } else { _watchVariablePanel.NotifySelectClick(this, isCtrlKeyHeld, isShiftKeyHeld); } }
public static Color FromHSL(double hue, double saturation, double luminosity) { return(ColorUtilities.FromHSL(hue, saturation, luminosity)); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } this.KeyboardInput.Update(); this.MouseInput.Update(); if (this.KeyboardInput.Click(Keys.OemTilde)) { this.detailView = !this.detailView; } if (this.KeyboardInput.Click(Keys.Tab)) { this.currentSceneIndex = (this.currentSceneIndex + 1) % this.scenes.Length; this.renderSystem.Scene = this.scenes[this.currentSceneIndex]; } if (this.KeyboardInput.Click(Keys.F)) { this.IsFixedTimeStep = !this.IsFixedTimeStep; } if (this.KeyboardInput.Click(Keys.OemPlus)) { this.viewIndex = (this.viewIndex + 1) % this.viewOptions; } else if (this.KeyboardInput.Click(Keys.OemMinus)) { this.viewIndex = (this.viewIndex + this.viewOptions - 1) % this.viewOptions; } if (this.KeyboardInput.Click(Keys.LeftControl)) { this.renderSystem.EnableFXAA = !this.renderSystem.EnableFXAA; } // HACK: dropping some lights var selectedScene = this.scenes[this.currentSceneIndex]; if (this.KeyboardInput.Click(Keys.Q)) { var color = ColorUtilities.PickRandomColor(); var light = new PointLight(this.camera.Position, color, 10, 1.0f); selectedScene.PointLights.Add(light); } if (this.KeyboardInput.Click(Keys.LeftAlt)) { var light = new ShadowCastingLight(this.GraphicsDevice, this.camera.Position, this.camera.LookAt, Color.White); selectedScene.ShadowCastingLights.Add(light); } if (this.KeyboardInput.Click(Keys.H)) { selectedScene.Sunlights.ForEach(x => x.Move(this.camera.Position, this.camera.LookAt)); } this.cameraController.Update(gameTime.ElapsedGameTime); this.renderSystem.Scene.Update(gameTime.ElapsedGameTime); base.Update(gameTime); }
private void InitializeKnownColorsWithoutTransparentList() { _knownColorsListBox.ItemsSource = ColorUtilities.GetKnownColorsWithoutTransparent(); }
protected virtual void OnUsingAlphaChannelChanged() { SetHexadecimalStringProperty(ColorUtilities.GetFormatedColorString(SelectedColor, UsingAlphaChannel), false); }
private bool CompareColors(Color first, Color second) { return(ColorUtilities.ColorDistance(first, second, distanceAlgorithm) <= tolerance); }
private string GetFormatedColorString(string stringToFormat) { return(ColorUtilities.FormatColorString(stringToFormat, UsingAlphaChannel)); }
private void SelectHue(float value) { SelectedHue = ColorUtilities.ConvertHsvToRgb(360 - value, 1, 1); }
/// <summary> /// Sets up the line chart series. /// </summary> protected override void SetupSeries() { // If no books return the default. if (BooksReadProvider == null) { base.SetupSeries(); return; } // Set up the axis names and formatters. XAxisTitle = "Date"; YAxisTitle = "Pages per Day"; // Setup the curve fitter. ICurveFitter curveFitter; GetPagesPerDayWithTimeCurveFitter(out curveFitter); // Set up the series for the overall and the trendline. Series = new SeriesCollection(); List <ISeriesView> seriesViews = new List <ISeriesView>(); List <DateTime> dates = new List <DateTime>(); List <double> overallSeriesValues = new List <double>(); List <double> overallTrendlineValues = new List <double>(); // Get the values. foreach (BooksDelta delta in BooksReadProvider.BookDeltas) { dates.Add(delta.Date); double trendPageRate = curveFitter.EvaluateYValueAtPoint(delta.DaysSinceStart); overallSeriesValues.Add(delta.OverallTally.PageRate); overallTrendlineValues.Add(trendPageRate); } seriesViews.Add(CreateLineSeries("Overall", dates, overallSeriesValues, Colors.Blue, 5d)); seriesViews.Add(CreateLineSeries("Overall trendline", dates, overallTrendlineValues, ColorUtilities.GetFaintColor(Colors.Red), 0d)); Series.AddRange(seriesViews); SeriesCollection = Series; MinY = Math.Floor(Math.Min(overallSeriesValues.Min(), overallTrendlineValues.Min())); MaxY = Math.Ceiling(Math.Max(overallSeriesValues.Max(), overallTrendlineValues.Max())); }
public override string ToString() { XDocument xmlBuild = new XDocument(); XElement root = new XElement("Data", _name); xmlBuild.Add(root); if (_groupList.Count > 0) { root.Add(new XAttribute("groupList", String.Join(",", _groupList))); } root.Add(new XAttribute("base", _watchVar.BaseAddressType.ToString())); if (_watchVar.OffsetDefault != null) { root.Add(new XAttribute( "offset", String.Format("0x{0:X}", _watchVar.OffsetDefault.Value))); } if (_watchVar.OffsetUS != null) { root.Add(new XAttribute( "offsetUS", String.Format("0x{0:X}", _watchVar.OffsetUS.Value))); } if (_watchVar.OffsetJP != null) { root.Add(new XAttribute( "offsetJP", String.Format("0x{0:X}", _watchVar.OffsetJP.Value))); } if (_watchVar.OffsetPAL != null) { root.Add(new XAttribute( "offsetPAL", String.Format("0x{0:X}", _watchVar.OffsetPAL.Value))); } if (_watchVar.MemoryTypeName != null) { root.Add(new XAttribute("type", _watchVar.MemoryTypeName)); } if (_watchVar.SpecialType != null) { root.Add(new XAttribute("specialType", _watchVar.SpecialType)); } if (_watchVar.Mask != null) { root.Add(new XAttribute( "mask", String.Format("0x{0:X" + _watchVar.NibbleCount + "}", _watchVar.Mask.Value))); } if (_subclass != WatchVariableSubclass.Number) { root.Add(new XAttribute("subclass", _subclass.ToString())); } if (_invertBool.HasValue) { root.Add(new XAttribute("invertBool", _invertBool.Value.ToString().ToLower())); } if (_useHex.HasValue) { root.Add(new XAttribute("useHex", _useHex.Value.ToString().ToLower())); } if (_coordinate.HasValue) { root.Add(new XAttribute("coord", _coordinate.Value.ToString())); } if (_backgroundColor.HasValue) { root.Add(new XAttribute( "color", "#" + ColorUtilities.ToString(_backgroundColor.Value))); } return(root.ToString()); }
private string GetFormatedColorString(Color colorToFormat) { return(ColorUtilities.FormatColorString(colorToFormat.GetColorName(), UsingAlphaChannel)); }
private void RefreshPreviews() { this.job = this.mainViewModel.EncodeJob; OutputSizeInfo newOutputSizeInfo = this.outputSizeService.Size; int width = newOutputSizeInfo.OutputWidth; int height = newOutputSizeInfo.OutputHeight; int parWidth = newOutputSizeInfo.Par.Num; int parHeight = newOutputSizeInfo.Par.Den; if (parWidth <= 0 || parHeight <= 0) { this.HasPreview = false; StaticResolver.Resolve <IAppLogger>().LogError("HandBrake returned a negative pixel aspect ratio. Cannot show preview."); return; } if (width < 100 || height < 100) { this.HasPreview = false; return; } this.OutputSizeInfo = newOutputSizeInfo; var profile = this.PresetsService.SelectedPreset.Preset.EncodingProfile; this.PadColor = ColorUtilities.ToWindowsColor(profile.PadColor); // Update the number of previews. this.previewCount = this.ScanInstance.PreviewCount; foreach (PreviewImageServiceClient client in this.clients.Items) { if (client.PreviewIndex >= this.previewCount) { client.PreviewIndex = this.previewCount - 1; } } this.RaisePropertyChanged(nameof(this.PreviewCount)); this.HasPreview = true; lock (this.imageSync) { this.previewImageCache = new BitmapSource[this.previewCount]; updateVersion++; // Clear main work queue. this.previewImageWorkQueue.Clear(); // Clear old images out of the file cache. this.ClearImageFileCache(); this.imageFileSync = new List <object>(this.previewCount); for (int i = 0; i < this.previewCount; i++) { this.imageFileSync.Add(new object()); } this.BeginBackgroundImageLoad(); } }
/// <summary> /// Sets up the scatter chart series. /// </summary> protected override void SetupSeries() { // If no books return the default. if (BooksReadProvider == null) { base.SetupSeries(); return; } // Set up the empty series set and the color range. Series = new SeriesCollection(); List <ISeriesView> seriesViews = new List <ISeriesView>(); List <Color> colors = ColorUtilities.Jet(NumberOfColors); // End date, daysTaken, pagesRead, rate List <Tuple <DateTime, double, double, double> > points = new List <Tuple <DateTime, double, double, double> >(); // Set up the list of deltas with to add points for and the range they lie between. List <BooksDelta> deltasSet = new List <BooksDelta>(); double minRate = 1e16; double maxRate = 0.0; foreach (BooksDelta delta in BooksReadProvider.BookDeltas) { deltasSet.Add(delta); if (deltasSet.Count < 10) { continue; } BooksDelta end = deltasSet.Last(); double daysTaken = end.LastTenTally.DaysInTally; double pagesRead = end.LastTenTally.TotalPages; if (daysTaken < 1.0) { daysTaken = 1.0; } double rate = pagesRead / daysTaken; points.Add(new Tuple <DateTime, double, double, double>(end.Date, daysTaken, pagesRead, rate)); if (minRate > rate) { minRate = rate; } if (maxRate < rate) { maxRate = rate; } deltasSet.RemoveAt(0); } // Add a series per point. foreach (Tuple <DateTime, double, double, double> point in points) { Color color = GetPointColorForRate(point.Item4, minRate, maxRate, colors); ScatterSeries pointSeries = CreateScatterSeries( point.Item1.ToString("ddd d MMM yyy") + " Page Rate = " + point.Item4.ToString("G3"), point.Item2, point.Item3, color, 9); seriesViews.Add(pointSeries); } Series.AddRange(seriesViews); SeriesCollection = Series; }
void DrawWheel(ref Vector4 value, bool overrideState, TrackballAttribute attr) { var wheelRect = GUILayoutUtility.GetAspectRect(1f); float size = wheelRect.width; float hsize = size / 2f; float radius = 0.38f * size; Vector3 hsv; Color.RGBToHSV(value, out hsv.x, out hsv.y, out hsv.z); float offset = value.w; // Thumb var thumbPos = Vector2.zero; float theta = hsv.x * (Mathf.PI * 2f); thumbPos.x = Mathf.Cos(theta + (Mathf.PI / 2f)); thumbPos.y = Mathf.Sin(theta - (Mathf.PI / 2f)); thumbPos *= hsv.y * radius; // Draw the wheel if (Event.current.type == EventType.Repaint) { // Retina support float scale = EditorGUIUtility.pixelsPerPoint; if (s_Material == null) { s_Material = new Material(Shader.Find("Hidden/PostProcessing/Editor/Trackball")) { hideFlags = HideFlags.HideAndDontSave } } ; // Wheel texture #if UNITY_2018_1_OR_NEWER const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.sRGB; #else const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.Linear; #endif var oldRT = RenderTexture.active; var rt = RenderTexture.GetTemporary((int)(size * scale), (int)(size * scale), 0, RenderTextureFormat.ARGB32, kReadWrite); s_Material.SetFloat("_Offset", offset); s_Material.SetFloat("_DisabledState", overrideState ? 1f : 0.5f); s_Material.SetVector("_Resolution", new Vector2(size * scale, size * scale / 2f)); Graphics.Blit(null, rt, s_Material, EditorGUIUtility.isProSkin ? 0 : 1); RenderTexture.active = oldRT; GUI.DrawTexture(wheelRect, rt); RenderTexture.ReleaseTemporary(rt); var thumbSize = Styling.wheelThumbSize; var thumbSizeH = thumbSize / 2f; Styling.wheelThumb.Draw(new Rect(wheelRect.x + hsize + thumbPos.x - thumbSizeH.x, wheelRect.y + hsize + thumbPos.y - thumbSizeH.y, thumbSize.x, thumbSize.y), false, false, false, false); } // Input var bounds = wheelRect; bounds.x += hsize - radius; bounds.y += hsize - radius; bounds.width = bounds.height = radius * 2f; hsv = GetInput(bounds, hsv, thumbPos, radius); value = Color.HSVToRGB(hsv.x, hsv.y, 1f); value.w = offset; // Offset var sliderRect = GUILayoutUtility.GetRect(1f, 17f); float padding = sliderRect.width * 0.05f; // 5% padding sliderRect.xMin += padding; sliderRect.xMax -= padding; value.w = GUI.HorizontalSlider(sliderRect, value.w, -1f, 1f); if (attr.mode == TrackballAttribute.Mode.None) { return; } // Values var displayValue = Vector3.zero; switch (attr.mode) { case TrackballAttribute.Mode.Lift: displayValue = ColorUtilities.ColorToLift(value); break; case TrackballAttribute.Mode.Gamma: displayValue = ColorUtilities.ColorToInverseGamma(value); break; case TrackballAttribute.Mode.Gain: displayValue = ColorUtilities.ColorToGain(value); break; } using (new EditorGUI.DisabledGroupScope(true)) { var valuesRect = GUILayoutUtility.GetRect(1f, 17f); valuesRect.width /= 3f; GUI.Label(valuesRect, displayValue.x.ToString("F2"), EditorStyles.centeredGreyMiniLabel); valuesRect.x += valuesRect.width; GUI.Label(valuesRect, displayValue.y.ToString("F2"), EditorStyles.centeredGreyMiniLabel); valuesRect.x += valuesRect.width; GUI.Label(valuesRect, displayValue.z.ToString("F2"), EditorStyles.centeredGreyMiniLabel); valuesRect.x += valuesRect.width; } } void DrawLabelAndOverride(GUIContent title, SerializedProperty overrideState) { // Title var areaRect = GUILayoutUtility.GetRect(1f, 17f); var labelSize = Styling.wheelLabel.CalcSize(title); var labelRect = new Rect(areaRect.x + areaRect.width / 2 - labelSize.x / 2, areaRect.y, labelSize.x, labelSize.y); GUI.Label(labelRect, title, Styling.wheelLabel); // Override checkbox var overrideRect = new Rect(labelRect.x - 17, labelRect.y + 3, 17f, 17f); EditorUtilities.DrawOverrideCheckbox(overrideRect, overrideState); } Vector3 GetInput(Rect bounds, Vector3 hsv, Vector2 thumbPos, float radius) { var e = Event.current; var id = GUIUtility.GetControlID(k_ThumbHash, FocusType.Passive, bounds); var mousePos = e.mousePosition; if (e.type == EventType.MouseDown && GUIUtility.hotControl == 0 && bounds.Contains(mousePos)) { if (e.button == 0) { var center = new Vector2(bounds.x + radius, bounds.y + radius); float dist = Vector2.Distance(center, mousePos); if (dist <= radius) { e.Use(); m_CursorPos = new Vector2(thumbPos.x + radius, thumbPos.y + radius); GUIUtility.hotControl = id; GUI.changed = true; } } else if (e.button == 1) { e.Use(); GUI.changed = true; m_ResetState = true; } } else if (e.type == EventType.MouseDrag && e.button == 0 && GUIUtility.hotControl == id) { e.Use(); GUI.changed = true; m_CursorPos += e.delta * GlobalSettings.trackballSensitivity; GetWheelHueSaturation(m_CursorPos.x, m_CursorPos.y, radius, out hsv.x, out hsv.y); } else if (e.rawType == EventType.MouseUp && e.button == 0 && GUIUtility.hotControl == id) { e.Use(); GUIUtility.hotControl = 0; } return(hsv); } void GetWheelHueSaturation(float x, float y, float radius, out float hue, out float saturation) { float dx = (x - radius) / radius; float dy = (y - radius) / radius; float d = Mathf.Sqrt(dx * dx + dy * dy); hue = Mathf.Atan2(dx, -dy); hue = 1f - ((hue > 0) ? hue : (Mathf.PI * 2f) + hue) / (Mathf.PI * 2f); saturation = Mathf.Clamp01(d); } }
/// <summary> /// Create a Character in the specified tile. /// </summary> /// <param name="tile">The tile where the Character is placed.</param> public Character Create(Tile tile) { return(Create(tile, ColorUtilities.RandomColor(), ColorUtilities.RandomGrayColor(), ColorUtilities.RandomSkinColor())); }
public static Color FromRGB(byte r, byte g, byte b) { return(ColorUtilities.FromRGB(r, g, b)); }