private ClassBreaksRenderer CreateClassBreaksRenderer() { // Define the colors that will be used by the unique value renderer. Colors gray = Colors.FromArgb(255, 153, 153, 153); Colors blue1 = Colors.FromArgb(255, 227, 235, 207); Colors blue2 = Colors.FromArgb(255, 150, 194, 191); Colors blue3 = Colors.FromArgb(255, 97, 166, 181); Colors blue4 = Colors.FromArgb(255, 69, 125, 150); Colors blue5 = Colors.FromArgb(255, 41, 84, 120); // Create a gray outline and five fill symbols with different shades of blue. SimpleLineSymbol outlineSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, gray, 1); SimpleFillSymbol simpleFileSymbol1 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue1, outlineSimpleLineSymbol); SimpleFillSymbol simpleFileSymbol2 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue2, outlineSimpleLineSymbol); SimpleFillSymbol simpleFileSymbol3 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue3, outlineSimpleLineSymbol); SimpleFillSymbol simpleFileSymbol4 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue4, outlineSimpleLineSymbol); SimpleFillSymbol simpleFileSymbol5 = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, blue5, outlineSimpleLineSymbol); // Create a list of five class breaks for different population ranges. List <ClassBreak> listClassBreaks = new List <ClassBreak> { new ClassBreak("-99 to 8560", "-99 to 8560", -99, 8560, simpleFileSymbol1), new ClassBreak("> 8,560 to 18,109", "> 8,560 to 18,109", 8560, 18109, simpleFileSymbol2), new ClassBreak("> 18,109 to 35,501", "> 18,109 to 35,501", 18109, 35501, simpleFileSymbol3), new ClassBreak("> 35,501 to 86,100", "> 35,501 to 86,100", 35501, 86100, simpleFileSymbol4), new ClassBreak("> 86,100 to 10,110,975", "> 86,100 to 10,110,975", 86100, 10110975, simpleFileSymbol5) }; // Create and return the a class break renderer for use with the POP2007 field in the counties sub-layer. return(new ClassBreaksRenderer("POP2007", listClassBreaks)); }
public VectorInkStroke(Stroke stroke, Wacom.Ink.Geometry.VectorBrush vectorBrush, PipelineData pipelineData) { Id = stroke.Id; PathPointProperties ppp = stroke.Style.PathPointProperties; Color = MediaColor.FromArgb( ppp.Alpha.HasValue ? (byte)(ppp.Alpha * 255.0f) : byte.MinValue, ppp.Red.HasValue ? (byte)(ppp.Red * 255.0f) : byte.MinValue, ppp.Green.HasValue ? (byte)(ppp.Green * 255.0f) : byte.MinValue, ppp.Blue.HasValue ? (byte)(ppp.Blue * 255.0f) : byte.MinValue); Spline = stroke.Spline; Layout = stroke.Layout; VectorBrush = vectorBrush; Polygon = PolygonUtil.ConvertPolygon(pipelineData.Merged.Addition); SimplPoly = pipelineData.Merged.Addition; SensorDataOffset = stroke.SensorDataOffset; SensorDataMappings = stroke.SensorDataMappings; SensorDataId = stroke.SensorDataId; Attributes attribs = new Attributes(Color); if (ppp.Size.HasValue) { attribs.Size = ppp.Size.Value; } Constants = attribs; }
/// <summary> /// This method returns a Border representing the shadow of the box /// </summary> /// <param name="shadowColour">Colour of the shadow</param> /// <param name="cornerRadius">Corner radius of the box</param> /// <param name="boxBorderThickness">Thickness of the box border</param> /// <param name="xDeltaPosition">X Translation of the shadow from the box</param> /// <param name="yDeltaPosition">Y Translation of the shadow from the box</param> /// <param name="boxColourAlpha">Alpha (opacity) of the box colour</param> /// <param name="boxBorderAlpha">Alpha (opacity) of the box border colour</param> /// <returns>Border</returns> private Border CreateShadow(XFColor shadowColour, CornerRadius cornerRadius, double boxBorderThickness, double xDeltaPosition, double yDeltaPosition, double boxColourAlpha, double boxBorderAlpha) { // Create a rectangle representing the shadow //Adjust the shadow color to account for any transparency in the box. XFColor clr = new XFColor(shadowColour.R, shadowColour.G, shadowColour.B, shadowColour.A * boxColourAlpha); XFColor borderClr = new XFColor(shadowColour.R, shadowColour.G, shadowColour.B, shadowColour.A * boxBorderAlpha); UWPColor shdwColour = UWPColor.FromArgb((byte)(255 * (clr.A < 0f ? 0 : clr.A)), (byte)(255 * (clr.R < 0f ? 0 : clr.R)), (byte)(255 * (clr.G < 0f ? 0 : clr.G)), (byte)(255 * (clr.B < 0f ? 0 : clr.B))); UWPColor shadowBorderColour = UWPColor.FromArgb((byte)(255 * (borderClr.A < 0f ? 0 : borderClr.A)), (byte)(255 * (borderClr.R < 0f ? 0 : borderClr.R)), (byte)(255 * (borderClr.G < 0f ? 0 : borderClr.G)), (byte)(255 * (borderClr.B < 0f ? 0 : borderClr.B))); return(new Border { Background = new SolidColorBrush(shdwColour), BorderBrush = new SolidColorBrush(shadowBorderColour), BorderThickness = new UWPThickness(boxBorderThickness), CornerRadius = CornerRadiusConverter.Convert(cornerRadius), RenderTransform = new CompositeTransform { TranslateX = xDeltaPosition, TranslateY = yDeltaPosition } }); }
public MasterDetailPageContentDemoViewModel() { SplitterMode = MasterDetailPageContentSplitterMode.OverlayVisible; EnableSplitter = true; Dictionary <string, Color> colors = new Dictionary <string, Color>(); Random rnd = new Random(); foreach (Message message in DataStorage.Messages) { Color color; if (colors.ContainsKey(message.From)) { color = colors[message.From]; } else { byte[] rgb = new byte[3]; rnd.NextBytes(rgb); color = Color.FromArgb(0xFF, rgb[0], rgb[1], rgb[2]); colors.Add(message.From, color); } Messages.Add(new MessageViewModel(message, color)); } SelectedMessage = Messages[0]; }
public static UWPColor ToColor(this Color target) { return(UWPColor.FromArgb( (byte)(255 * target.A), (byte)(255 * target.R), (byte)(255 * target.G), (byte)(255 * target.B))); }
public static Color ToPlatform(this IInk.Graphics.Color source) { return(Color.FromArgb( Convert.ToByte(source.A), Convert.ToByte(source.R), Convert.ToByte(source.G), Convert.ToByte(source.B))); }
public static WColor ColorAtPoint(this CanvasBitmap bitmap, int x, int y, bool includeAlpha = false) { var pixel = bitmap.GetPixelColors(x, y, 1, 1)[0]; return(includeAlpha ? pixel : WColor.FromArgb(255, pixel.R, pixel.G, pixel.B)); }
Palette CreateUrbanRuralDivisionDynamicPalette() { CustomPalette palette = new CustomPalette(); palette.Colors.Add(Color.FromArgb(0xFF, 0xC5, 0x64, 0x50)); palette.Colors.Add(Color.FromArgb(0xFF, 0x5F, 0x8B, 0x95)); return(palette); }
public SolidColorBrush ColorConverter(string hex) { var r = (byte)System.Convert.ToUInt32(hex.Substring(0, 2), 16); var g = (byte)System.Convert.ToUInt32(hex.Substring(2, 2), 16); var b = (byte)System.Convert.ToUInt32(hex.Substring(4, 2), 16); return(new SolidColorBrush(Color.FromArgb(255, r, g, b))); }
public static NativeColor ToWindows(this Color color) { return(NativeColor.FromArgb( (byte)(color.A * 255), (byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255))); }
private UWPGrid CreateExtendedBox() { UWPGrid grid = new UWPGrid(); ExtendedBoxView ebv = (ExtendedBoxView)this.Element; if (ebv.IsVisible) { // Convert the parameters in the Forms Element so they can be used in the Native Control XFColor rectClr = ebv.Color; UWPColor rectColour = UWPColor.FromArgb((byte)(255 * (rectClr.A < 0f ? 0 : rectClr.A)), (byte)(255 * (rectClr.R < 0f ? 0 : rectClr.R)), (byte)(255 * (rectClr.G < 0f ? 0 : rectClr.G)), (byte)(255 * (rectClr.B < 0f ? 0 : rectClr.B))); XFColor brdClr = ebv.BorderColor; UWPColor brdColour = UWPColor.FromArgb((byte)(255 * (brdClr.A < 0f ? 0 : brdClr.A)), (byte)(255 * (brdClr.R < 0f ? 0 : brdClr.R)), (byte)(255 * (brdClr.G < 0f ? 0 : brdClr.G)), (byte)(255 * (brdClr.B < 0f ? 0 : brdClr.B))); // Set up a rectangle representing the Box // Note1: Don't need to specify the Layout options or size of the Rectangle, as it will fill the cell contained // in the grid. So the cell and grid layout will dictate the size and layout behaviour of the rectangle. // Note2: (Setting the layout and/or size of the rectangle will override those of the cell/grid. This may // cause some of the behaviour to be different than expected, even if manually picking up the values // from the Forms control) Border rect = new Border { Background = new SolidColorBrush(rectColour), BorderBrush = new SolidColorBrush(brdColour), BorderThickness = new UWPThickness(ebv.BorderThickness), CornerRadius = CornerRadiusConverter.Convert(ebv.CornerRadius) }; // Set up a rectangle representing the Shadow if (ebv.HasShadow) { Border shadow = CreateShadow(ebv.ShadowColor, ebv.CornerRadius, ebv.BorderThickness, ebv.ShadowPosition.dX, ebv.ShadowPosition.dY, ebv.Color.A, ebv.BorderColor.A); grid.Children.Add(shadow); } // Add the box rectangle to the grid // Note: The default behaviour for a grid with no column definitions or row definitions is a single cell // filling the available space in the grid. The windows layout system and the forms layout system // interact to automatically layout cell according to the LayoutOptions and Size Requests // specified in the Forms control grid.Children.Add(rect); } return(grid); }
private void UpdateTint(AcrylicState state, bool invalidate = true) { var tintColorWithOpacity = Color.FromArgb( (byte)(TintOpacity * TintColor.A), TintColor.R, TintColor.G, TintColor.B); Android.Graphics.Color tintColor = tintColorWithOpacity; state.BlurView?.SetOverlayColor(tintColor, invalidate); }
public MainPage() { this.InitializeComponent(); MainViewModel viewModel = new MainViewModel(new NavigationService(MainPageFrame)); this.DataContext = viewModel; ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; Color backGroundColor = Color.FromArgb(255, 201, 158, 103); titleBar.BackgroundColor = backGroundColor; titleBar.ButtonBackgroundColor = backGroundColor; }
void AddColorLine(ColorPalette ColorsList, byte r, byte g, byte b, int hi, int lo, int step) { ColorsList.Items.Add(new SolidColorBrush(Color.FromArgb(255, r, g, b))); for (int n = hi; n > lo; n -= step) { int colorDiff = 24 * n; byte r1 = (byte)(r + colorDiff > 255 ? 255 : (r + colorDiff < 0 ? 0 : r + colorDiff)); byte g1 = (byte)(g + colorDiff > 255 ? 255 : (g + colorDiff < 0 ? 0 : g + colorDiff)); byte b1 = (byte)(b + colorDiff > 255 ? 255 : (b + colorDiff < 0 ? 0 : b + colorDiff)); ColorsList.Items.Add(new SolidColorBrush(Color.FromArgb(255, r1, g1, b1))); } }
void SetPalettes() { CustomPalette palette = new CustomPalette(); palette.Colors.Add(Color.FromArgb(0xFF, 0x84, 0x96, 0x66)); foreach (Series series in cartesianChart.Series) { series.View.Palette = palette; ((ScatterLineSeriesView)series.View).StrokeStyle = new StrokeStyle() { Thickness = 2 }; } }
private void MyMapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { try { // Create a map point (in the WebMercator projected coordinate system) from the GUI screen coordinate. MapPoint userTappedMapPoint = MyMapView.ScreenToLocation(e.Position); // Get the buffer size from the textbox. double bufferInMiles = System.Convert.ToDouble(BufferDistanceMilesEntry.Text); // Create a variable to be the buffer size in meters. There are 1609.34 meters in one mile. double bufferInMeters = bufferInMiles * 1609.34; // Get a buffered polygon from the GeometryEngine Buffer operation centered on the map point. // Note: The input distance to the Buffer operation is in meters. This matches the backdrop // basemap units which is also meters. Geometry bufferGeometry = GeometryEngine.Buffer(userTappedMapPoint, bufferInMeters); // Create the outline (a simple line symbol) for the buffered polygon. It will be a solid, thick, green line. SimpleLineSymbol bufferSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Green, 5); // Create the color that will be used for the fill of the buffered polygon. It will be a semi-transparent, green color. Colors2 bufferFillColor = Colors2.FromArgb(125, 0, 255, 0); // Create simple fill symbol for the buffered polygon. It will be solid, semi-transparent, green fill with a solid, // thick, green outline. SimpleFillSymbol bufferSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, bufferFillColor, bufferSimpleLineSymbol); // Create a new graphic for the buffered polygon using the defined simple fill symbol. Graphic bufferGraphic = new Graphic(bufferGeometry, bufferSimpleFillSymbol); // Add the buffered polygon graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(bufferGraphic); // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol will be a // solid, red circle. SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Red, 5); // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol. Graphic userTappedGraphic = new Graphic(userTappedMapPoint, userTappedSimpleMarkerSymbol); // Add the user tapped/clicked map point graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(userTappedGraphic); } catch (System.Exception ex) { // Display an error message if there is a problem generating the buffer polygon. DisplayAlert("Error", "Geometry Engine Failed: " + ex.Message, "OK"); } }
private void BufferButton_Clicked(object sender, EventArgs e) { try { // Get the boolean value whether to create a single unioned buffer (true) or independent buffer around each map point (false). bool unionBufferBool = (bool)UnionSwitch.IsToggled; // Create an IEnumerable that contains buffered polygon(s) from the GeometryEngine Buffer operation based on a list of map // points and list of buffered distances. The input distances used in the Buffer operation are in meters; this matches the // backdrop basemap units which are also meters. If the unionResult parameter is true create a single unioned buffer, else // independent buffers will be created around each map point. IEnumerable <Geometry> theIEnumerableOfGeometryBuffer = GeometryEngine.Buffer(_bufferPointsList, _bufferDistancesList, unionBufferBool); // Loop through all the geometries in the IEnumerable from the GeometryEngine Buffer operation. There should only be one buffered // polygon returned from the IEnumerable collection if the bool unionResult parameter was set to true in the GeometryEngine.Buffer // operation. If the bool unionResult parameter was set to false there will be one buffer per input geometry. foreach (Geometry oneGeometry in theIEnumerableOfGeometryBuffer) { // Create the outline (a simple line symbol) for the buffered polygon. It will be a solid, thick, green line. SimpleLineSymbol bufferPolygonSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Green, 5); // Create the color that will be used for the fill of the buffered polygon. It will be a semi-transparent, yellow color. Colors2 bufferPolygonFillColor = Colors2.FromArgb(155, 255, 255, 0); // Create simple fill symbol for the buffered polygon. It will be solid, semi-transparent, yellow fill with a solid, // thick, green outline. SimpleFillSymbol bufferPolygonSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, bufferPolygonFillColor, bufferPolygonSimpleLineSymbol); // Create a new graphic for the buffered polygon using the defined simple fill symbol. Graphic bufferPolygonGraphic = new Graphic(oneGeometry, bufferPolygonSimpleFillSymbol); // Specify a ZIndex value on the buffered polygon graphic to assist with the drawing order of mixed geometry types being added // to a single GraphicCollection. The lower the ZIndex value, the lower in the visual stack the graphic is drawn. Typically, // Polygons would have the lowest ZIndex value (ex: 0), then Polylines (ex: 1), and finally MapPoints (ex: 2). bufferPolygonGraphic.ZIndex = 0; // Add the buffered polygon graphic to the graphic overlay. // NOTE: While you can control the positional placement of a graphic within the GraphicCollection of a GraphicsOverlay, // it does not impact the drawing order in the GUI. If you have mixed geometries (i.e. Polygon, Polyline, MapPoint) within // a single GraphicsCollection, the way to control the drawing order is to specify the Graphic.ZIndex. _graphicsOverlay.Graphics.Insert(0, bufferPolygonGraphic); } } catch (System.Exception ex) { // Display an error message if there is a problem generating the buffer polygon. DisplayAlert("Geometry Engine Failed", "Error creating list of map points for buffer: " + ex.Message, "OK"); } }
private void PlaceToDragDrop_OnDragOver(object sender, DragEventArgs e) { e.AcceptedOperation = DataPackageOperation.Copy; if (e.DragUIOverride == null) { return; } e.DragUIOverride.Caption = "drop to create a custom sound and tile"; e.DragUIOverride.IsCaptionVisible = true; e.DragUIOverride.IsContentVisible = true; e.DragUIOverride.IsGlyphVisible = true; PlaceToDragDrop.Background = new SolidColorBrush(Color.FromArgb(255, 120, 120, 120)); }
public static SolidColorBrush GetBrush(this Color color) { var b = color.Tag as SolidColorBrush; if (b == null) { b = new SolidColorBrush( NativeColor.FromArgb( (byte)color.Alpha, (byte)color.Red, (byte)color.Green, (byte)color.Blue)); color.Tag = b; } return(b); }
private void Initialize() { // Create a map with a topographic basemap. Map newMap = new Map(Basemap.CreateTopographic()); // Assign the map to the MapView. MyMapView.Map = newMap; // Create a graphics overlay to hold the various graphics. _graphicsOverlay = new GraphicsOverlay(); // Add the created graphics overlay to the MapView. MyMapView.GraphicsOverlays.Add(_graphicsOverlay); // Create a simple line symbol for the outline for the two input polygon graphics. SimpleLineSymbol polygonsSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Blue, 4); // Create the color that will be used for the fill of the two input polygon graphics. It will be a // semi -transparent, blue color. Colors2 polygonsFillColor = Colors2.FromArgb(34, 0, 0, 255); // Create the simple fill symbol for the two input polygon graphics - comprised of a fill style, fill // color and outline. SimpleFillSymbol polygonsSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, polygonsFillColor, polygonsSimpleLineSymbol); // Create the graphic for polygon1 - comprised of a polygon shape and fill symbol. _polygonGraphic1 = new Graphic(CreatePolygon1(), polygonsSimpleFillSymbol); // Set the Z index for the polygon1 graphic so that it appears above the convex hull graphic(s) added later. _polygonGraphic1.ZIndex = 1; // Add the polygon1 graphic to the graphics overlay collection. _graphicsOverlay.Graphics.Add(_polygonGraphic1); // Create the graphic for polygon2 - comprised of a polygon shape and fill symbol. _polygonGraphic2 = new Graphic(CreatePolygon2(), polygonsSimpleFillSymbol); // Set the Z index for the polygon2 graphic so that it appears above the convex hull graphic(s) added later. _polygonGraphic2.ZIndex = 1; // Add the polygon2 graphic to the graphics overlay collection. _graphicsOverlay.Graphics.Add(_polygonGraphic2); }
public CutGeometry() { InitializeComponent(); Title = "Cut geometry"; // Create a map with a topographic basemap. Map newMap = new Map(Basemap.CreateTopographic()); // Assign the map to the MapView. MyMapView.Map = newMap; // Create a graphics overlay to hold the various graphics. _graphicsOverlay = new GraphicsOverlay(); // Add the created graphics overlay to the MapView. MyMapView.GraphicsOverlays.Add(_graphicsOverlay); // Create a simple line symbol for the outline of the Lake Superior graphic. SimpleLineSymbol lakeSuperiorSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Blue, 4); // Create the color that will be used for the fill the Lake Superior graphic. It will be a semi-transparent, blue color. Colors2 lakeSuperiorFillColor = Colors2.FromArgb(34, 0, 0, 255); // Create the simple fill symbol for the Lake Superior graphic - comprised of a fill style, fill color and outline. SimpleFillSymbol lakeSuperiorSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, lakeSuperiorFillColor, lakeSuperiorSimpleLineSymbol); // Create the graphic for Lake Superior - comprised of a polygon shape and fill symbol. _lakeSuperiorPolygonGraphic = new Graphic(CreateLakeSuperiorPolygon(), lakeSuperiorSimpleFillSymbol); // Add the Lake Superior graphic to the graphics overlay collection. _graphicsOverlay.Graphics.Add(_lakeSuperiorPolygonGraphic); // Create a simple line symbol for the Canada and USA border (polyline) of Lake Superior. SimpleLineSymbol countryBorderSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Colors.Red, 5); // Create the graphic for Canada and USA border (polyline) of Lake Superior - comprised of a polyline shape and line symbol. _countryBorderPolylineGraphic = new Graphic(CreateBorder(), countryBorderSimpleLineSymbol); // Add the Canada and USA border graphic to the graphics overlay collection. _graphicsOverlay.Graphics.Add(_countryBorderPolylineGraphic); // Set the initial visual extent of the map view to that of Lake Superior. MyMapView.SetViewpointGeometryAsync(_lakeSuperiorPolygonGraphic.Geometry); }
void OnDeltaPriceChanged(object oldValue, double newValue) { double old = Convert.ToDouble(oldValue); if (Math.Sign(old) == Math.Sign(newValue)) { Background = new SolidColorBrush(Colors.Transparent); return; } if (newValue < 0) { Background = new SolidColorBrush(Color.FromArgb(230, 230, 210, 216)); } if (newValue > 0) { Background = new SolidColorBrush(Color.FromArgb(230, 210, 227, 223)); } }
private void onScoreTimerTick(object sender, ScoreTimerTickEventArgs e) { if (e.ScoreTick > GameSettings.ScoreTime) { this.timeProgressBar.Foreground = new SolidColorBrush(Color.FromArgb(255, 218, 165, 32)); this.timeTwoValue.Visibility = Visibility.Visible; } else { this.timeProgressBar.Foreground = new SolidColorBrush(Color.FromArgb(255, 50, 205, 50)); this.timeTwoValue.Visibility = Visibility.Collapsed; } if (this.timeProgressBar.Value >= this.timeProgressBar.Minimum) { this.timeProgressBar.Value = e.ScoreTick; } }
protected override void OnElementChanged(ElementChangedEventArgs <BusyIndicator> e) { base.OnElementChanged(e); if (Control != null) { return; } var progressRing = new ProgressRing { IsActive = true, Visibility = Windows.UI.Xaml.Visibility.Visible, IsEnabled = true, Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) }; SetNativeControl(progressRing); }
private void setPixelToClosestQuantizedColor(List <QuantizedColor> colors, Color sourcePixelColor, double distance, int j, int i) { foreach (var quantizedColor in colors) { var color = quantizedColor.Color; var curDist = Math.Pow(color.R - sourcePixelColor.R, 2) + Math.Pow(color.G - sourcePixelColor.G, 2) + Math.Pow(color.B - sourcePixelColor.B, 2); if (curDist < distance) { distance = curDist; var newPixelColor = Color.FromArgb(255, color.R, color.G, color.B); PixelUtilities.SetPixelBgra8(this.sourcePicture.Pixels, j, i, newPixelColor, this.sourcePicture.Width, this.sourcePicture.Height); } } }
void UpdateDocumentColors(bool clear) { if (DocumentColors != null && RTFText != null) { if (clear) { DocumentColors.Items.Clear(); documentColorsMap.Clear(); } Regex rgx = new Regex(@"\\red([0-9]{1,3})\\green([0-9]{1,3})\\blue([0-9]{1,3})"); MatchCollection colorsMatches = rgx.Matches(RTFText); foreach (Match match in colorsMatches) { if (match.Groups.Count == 4) { Color color = Color.FromArgb(255, byte.Parse(match.Groups[1].Value), byte.Parse(match.Groups[2].Value), byte.Parse(match.Groups[3].Value)); AddDocumentColor(new SolidColorBrush(color)); } } } }
public RasterInkStroke(Stroke stroke, RasterBrush rasterBrush, ParticleList particleList, ParticleBrush particleBrush) { Id = stroke.Id; Path = particleList; RandomSeed = stroke.Style.RandomSeed; RasterBrush = rasterBrush; ParticleBrush = particleBrush; PathPointProperties ppp = stroke.Style.PathPointProperties; StrokeConstants = new StrokeConstants { Color = MediaColor.FromArgb( ppp.Alpha.HasValue ? (byte)(ppp.Alpha * 255.0f) : byte.MinValue, ppp.Red.HasValue ? (byte)(ppp.Red * 255.0f) : byte.MinValue, ppp.Green.HasValue ? (byte)(ppp.Green * 255.0f) : byte.MinValue, ppp.Blue.HasValue ? (byte)(ppp.Blue * 255.0f) : byte.MinValue) }; SensorDataId = stroke.SensorDataId; Spline = stroke.Spline; Layout = stroke.Layout; }
public static WindowsColor ToPlatformColor(this Color color) => WindowsColor.FromArgb(color.A, color.R, color.G, color.B);
public static SolidColorBrush ToBrush(this SColor color) { return(new SolidColorBrush(WColor.FromArgb(color.A, color.R, color.G, color.B))); }
public void BeginDrawing() { bmp.Clear(NativeColor.FromArgb(255, 255, 255, 255)); }