So I got this project where you're recording mouse movement and later on the output is a graphic table that shows the most active and the least active sectors. Something similar to
IOgraphica except I'm using rectangles and alpha color. Mouse coordinates are stored in txt file that later is being read and compared.
color.alpha is what I'm using to present the most used positions (sectors) on the monitor screen, where the minimum is 0/0.1 and maximum is 1 (0 is less used, 1 is the most used sector). There are total of 512 rectangles (32
width x16
height) I ran into the problem where label shows every sector with alpha 1 -
printed rectangles example . The output however, is alpha being constantly 0, until some point it is 0,0,
1,4,0,0,0 -
output example. The output should be something like
0.2, 0.4, 0.6 and so on.
Long story short: color alpha is not changing on printed rectangles and problem is laying somewhere in this for loop with bunch of math formulas and I completely lost track of everything and I can't find the solution. I am desperate.
Project is on
GitHub too.
What I have tried:
I've tried this:
List<ColorManager> colorManagers = new List<ColorManager>();
List<RectangleF> rectangles = new List<RectangleF>();
List <Point> ListOfPoints = getAllPoints();
int numberOfPoints = ListOfPoints.Count;
int screenWidth = Screen.PrimaryScreen.Bounds.Width;
int screenHeight = Screen.PrimaryScreen.Bounds.Height;
int widthStep = screenWidth / 32;
int heightStep = screenHeight / 16;
int currentWidthIndex = 1;
int currentHeightIndex = 1;
for (int i = 0; i < 32*16; i++)
{
RectangleF rectangle = new RectangleF(currentWidthIndex * widthStep - widthStep,
currentHeightIndex * heightStep -heightStep, widthStep, heightStep);
if (currentWidthIndex == 32)
{
currentHeightIndex++;
currentWidthIndex = 1;
}
else
{
currentWidthIndex++;
}
List<Point> pointsInRectangle = ListOfPoints.FindAll(p =>
{
if (p.X >= currentWidthIndex * widthStep - widthStep && p.X <= currentWidthIndex * widthStep && p.Y >= currentHeightIndex * heightStep - heightStep && p.Y <= currentHeightIndex * heightStep)
{
return true;
}
else
{
return false;
}
});
float alfa = pointsInRectangle.Count;
System.Console.WriteLine("alfa " + alfa);
SolidBrush sb = new SolidBrush(Color.FromArgb(pointsInRectangle.Count / numberOfPoints, 100, 0, 0));
ColorManager cm = new ColorManager(rectangle, sb, pointsInRectangle);
colorManagers.Add(cm);
}
foreach (ColorManager item in colorManagers)
{
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(163, 8, 8)), item.rectangleF);
}