<commit_before>﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace LTag
{
	class Drawing
	{
		private int _width = 1024;
		private int _height = 768;
		private int _drawPxDist = 5;
		private int _brushSize = 35;
		private float _brushOpacity = 0.9f;
		private Color _brushColor = Color.White;
		private Bitmap _bitmap;
		private Bitmap _brushBitmap;

		[Browsable(false)]
		public Bitmap Bitmap
		{
			get { return _bitmap; }
		}

		[Category("Brush")]
		public int DrawPxDist
		{
			get { return _drawPxDist; }
			set { _drawPxDist = value; }
		}

		[Category("Brush")]
		public float BrushOpacity
		{
			get { return _brushOpacity; }
			set { _brushOpacity = value; RecreateBrush(); }
		}

		[Category("Brush")]
		public Color BrushColor
		{
			get { return _brushColor; }
			set { _brushColor = value; RecreateBrush(); }
		}

		[Category("Brush")]
		public int BrushSize
		{
			get { return _brushSize; }
			set { _brushSize = value; RecreateBrush(); }
		}

		[Category("Output")]
		public int Width
		{
			get { return _width; }
			set { _width = value; RecreateBitmap(); }
		}

		[Category("Output")]
		public int Height
		{
			get { return _height; }
			set { _height = value; RecreateBitmap(); }
		}

		private void RecreateBrush()
		{
			var bitmap = new Bitmap(_brushSize, _brushSize, PixelFormat.Format32bppArgb);
			var center = new PointF(bitmap.Width / 2f, bitmap.Height / 2f);
			var sz = Math.Max(center.X, center.Y);
			var maxAlpha = (int) Math.Round(_brushOpacity*255);
			for(var y = 0; y < bitmap.Width; y++)
			{
				for (var x = 0; x < bitmap.Height; x++)
				{
					var dst = Math.Sqrt(Util.DistanceSqr(new PointF(x, y), center));
					dst = 1 - (dst/sz);
					var alpha = Math.Min(Math.Max((int)(dst * maxAlpha), 0), maxAlpha);
					bitmap.SetPixel(x, y, Color.FromArgb(alpha, _brushColor));
				}
			}
			Util.Dispose(ref _brushBitmap);
			_brushBitmap = bitmap;
		}

		private void RecreateBitmap()
		{
			var newBitmap = new Bitmap(_width, _height, PixelFormat.Format32bppArgb);
			using (var g = Graphics.FromImage(newBitmap))<commit_msg>Add brushbias<commit_after>﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace LTag
{
	class Drawing
	{
		private int _width = 1024;
		private int _height = 768;
		private int _drawPxDist = 5;
		private int _brushSize = 35;
		private float _brushOpacity = 0.9f;
		private float _brushBias = 1f;
		private Color _brushColor = Color.White;
		private Bitmap _bitmap;
		private Bitmap _brushBitmap;

		[Browsable(false)]
		public Bitmap Bitmap
		{
			get { return _bitmap; }
		}

		[Category("Brush")]
		public int DrawPxDist
		{
			get { return _drawPxDist; }
			set { _drawPxDist = value; }
		}

		[Category("Brush")]
		public float BrushOpacity
		{
			get { return _brushOpacity; }
			set { _brushOpacity = value; RecreateBrush(); }
		}

		[Category("Brush")]
		public float BrushBias
		{
			get { return _brushBias; }
			set { _brushBias = value; RecreateBrush(); }
		}

		[Category("Brush")]
		public Color BrushColor
		{
			get { return _brushColor; }
			set { _brushColor = value; RecreateBrush(); }
		}

		[Category("Brush")]
		public int BrushSize
		{
			get { return _brushSize; }
			set { _brushSize = value; RecreateBrush(); }
		}

		[Category("Output")]
		public int Width
		{
			get { return _width; }
			set { _width = value; RecreateBitmap(); }
		}

		[Category("Output")]
		public int Height
		{
			get { return _height; }
			set { _height = value; RecreateBitmap(); }
		}

		private void RecreateBrush()
		{
			var bitmap = new Bitmap(_brushSize, _brushSize, PixelFormat.Format32bppArgb);
			var center = new PointF(bitmap.Width / 2f, bitmap.Height / 2f);
			var sz = Math.Max(center.X, center.Y);
			var maxAlpha = (int) Math.Round(_brushOpacity*255);
			for(var y = 0; y < bitmap.Width; y++)
			{
				for (var x = 0; x < bitmap.Height; x++)
				{
					var dst = Math.Sqrt(Util.DistanceSqr(new PointF(x, y), center));
					dst = 1 - (dst/sz);
					dst = Math.Pow(dst, _brushBias);
					var alpha = Math.Min(Math.Max((int)(dst * maxAlpha), 0), maxAlpha);
					bitmap.SetPixel(x, y, Color.FromArgb(alpha, _brushColor));
				}
			}
			Util.Dispose(ref _brushBitmap);
			_brushBitmap = bitmap;
		}

		private void RecreateBitmap()
		{
			var newBitmap = new Bitmap(_width, _height, PixelFormat.Format32bppArgb);
			using (var g = Graphics.FromImage(newBitmap))
{'fraction_non_alphanumeric': 0.12547107071602748, 'fraction_numerical': 0.011749057858567944, 'mean_word_length': 3.330134357005758, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2171997', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1553, 'n_words': 396}