+ return fieldWidth / numRects[size];
+}
+
+void Field::tryFloodRecurse (quint8 brush, int x, int y)
+{
+ FieldRect &rect = data[x + y*numRects[size]];
+
+ if (!rect.flood && rect.brush == brush)
+ {
+ rect.flood = true;
+ floodNeighbours(brush, x, y);
+ }
+}
+
+void Field::floodNeighbours (quint8 brush, int x, int y)
+{
+ int s = numRects[size];
+
+ data[x + y*s].brush = brush;
+
+ if (x > 0)
+ tryFloodRecurse(brush, x - 1, y);
+
+ if (y > 0)
+ tryFloodRecurse(brush, x, y - 1);
+
+ if (x < s - 1)
+ tryFloodRecurse(brush, x + 1, y);
+
+ if (y < s - 1)
+ tryFloodRecurse(brush, x, y + 1);
+}
+
+void Field::mousePressEvent (QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton)
+ randomize();