//protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Button> e) //{ // base.OnElementChanged(e); // if (e?.NewElement == null) return; // Control.SetBackground(GetGradient()); //} //public GradientDrawable GetGradient() //{ // Android.Graphics.Color color = Element.BackgroundColor.ToAndroid(); // var gradient = new GradientDrawable(GradientDrawable.Orientation.BottomTop, new[]{ // Android.Graphics.Color.Black.ToArgb(), color.ToArgb(), Android.Graphics.Color.White.ToArgb() // }); // gradient.SetAlpha(200); // return gradient; //} public override void Draw(Canvas canvas) { //base.Draw(canvas); Android.Graphics.Color color = Element.BackgroundColor.ToAndroid(); float[] segments = null; var textGradient = new LinearGradient(0, Height / 3, 0, 2 * Height / 3, new int[] { Android.Graphics.Color.Rgb(142, 123, 95), Android.Graphics.Color.Black.ToArgb(), }, segments, Shader.TileMode.Mirror); var textPaint = new Paint() { TextAlign = Paint.Align.Center, TextSize = 50, }; textPaint.SetShader(textGradient); textPaint.SetShadowLayer(5f, 2f, 1f, Android.Graphics.Color.Black); var gradient = new LinearGradient(0, 0, 0, Height, new int[] { Android.Graphics.Color.White.ToArgb(), color.ToArgb(), Android.Graphics.Color.Black.ToArgb() }, segments, Shader.TileMode.Clamp ); var paint = new Paint(); paint.SetShader(gradient); var rect = new RectF(Left, Top, Right, Bottom); var borderPaint = new Paint(); borderPaint.SetShadowLayer(10f, 0, 0, Android.Graphics.Color.Black); borderPaint.SetStyle(Paint.Style.Stroke); var borderRect = new RectF(Left, Top, Right, Bottom); canvas.DrawRect(rect, paint); canvas.DrawRect(borderRect, borderPaint); canvas.DrawText(Element.Text, Width / 2, 2 * Height / 3, textPaint); }
public void background(Color c) { HostPaint.BgColor = c.ToArgb (); }
public static Color ToColor(this Android.Graphics.Color androidColor) { return(Color.FromArgb(androidColor.ToArgb())); }
public void set(double x, double y, Color c) { var bak = HostPaint.Color; HostPaint.Color = c.ToArgb (); Host.DrawPoint ((float) x, (float) y, HostPaint); HostPaint.Color = bak; }
private int[][] getPixelsSlow(Bitmap image) { int width = image.Width; int height = image.Height; int[][] result = new int[height][]; for (int row = 0; row < height; row++) { result [row] = new int[width]; for (int col = 0; col < width; col++) { int clr= image.GetPixel (col,row); Color c = new Color (clr); //Console.WriteLine ("{0} {1}",clr,c.ToString()); result [row] [col] = c.ToArgb (); } } return result; }
Paint GetOrCreateBrush( Color color ) { int key = color.ToArgb(); Paint brush; if( brushCache.TryGetValue( key, out brush ) ) return brush; brush = new Paint(); brush.AntiAlias = true; brush.Color = color; brush.FilterBitmap = true; brush.SetStyle( Paint.Style.FillAndStroke ); brushCache[key] = brush; return brush; }
private void HandleMarkerClick(object sender, GoogleMap.MarkerClickEventArgs e) { ClearMapOverlays (); Marker marker = e.Marker; int index = int.Parse (marker.Title); extendedMap.pin_Clicked (index ); Android.Graphics.Color clrb = new Android.Graphics.Color (12,92,169,130); Android.Graphics.Color clrr = new Android.Graphics.Color (204,27,39,130); PolygonOptions polygonOptions = new PolygonOptions(); switch (index) { case 0: CircleOptions circleOptions = new CircleOptions (); circleOptions.InvokeCenter (new LatLng (extendedMap.pinDatas [index].lat, extendedMap.pinDatas [index].lng)); circleOptions.InvokeRadius (2000); circleOptions.InvokeFillColor (clrb.ToArgb ()); circleOptions.InvokeStrokeColor (clrr.ToArgb ()); circle = map.AddCircle (circleOptions); break; case 1: polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng-0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng-0.01)); polygonOptions.InvokeFillColor (clrb.ToArgb()); polygonOptions.InvokeStrokeColor (clrr.ToArgb()); polygon = map.AddPolygon(polygonOptions); break; case 2: polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.01, extendedMap.pinDatas[index].lng+0.01)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.005, extendedMap.pinDatas[index].lng)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat+0.02, extendedMap.pinDatas[index].lng-0.02)); polygonOptions.Add(new LatLng(extendedMap.pinDatas[index].lat-0.01, extendedMap.pinDatas[index].lng-0.01)); polygonOptions.InvokeFillColor (clrb.ToArgb()); polygonOptions.InvokeStrokeColor (clrr.ToArgb()); polygon = map.AddPolygon(polygonOptions); break; default: CircleOptions circleOptions2 = new CircleOptions (); circleOptions2.InvokeCenter (new LatLng (extendedMap.pinDatas [index].lat, extendedMap.pinDatas [index].lng)); circleOptions2.InvokeRadius (2000); circleOptions2.InvokeFillColor (clrb.ToArgb ()); circleOptions2.InvokeStrokeColor (clrr.ToArgb ()); circle = map.AddCircle (circleOptions2); break; } }