Lines Matching refs:magnet
270 * Case 1 : Inside. Rect won't be move because it is already attracted by magnet.
295 * Case 3: Half Inside. R will be moved totally into magnet.
308 * Case 4: Outside or Half Outside but space not enough. R will be moved into magnet as more as possible.
321 * Case 5: Totally Across magnet. Nothing should happen.
336 * @param[in] magnet The magnetical rectangle.
338 * @return The offset that this rect need to moving into magnet.
340 Offset MagneticAttractedBy(const Rect& magnet)
343 if (IsWrappedBy(magnet)) {
347 if (Left() < magnet.Left()) {
348 offset.SetX(std::max(0.0, std::min(magnet.Left() - Left(), magnet.Right() - Right())));
349 } else if (Right() > magnet.Right()) {
350 offset.SetX(std::min(0.0, std::max(magnet.Left() - Left(), magnet.Right() - Right())));
353 if (Top() < magnet.Top()) {
354 offset.SetY(std::max(0.0, std::min(magnet.Top() - Top(), magnet.Bottom() - Bottom())));
355 } else if (Bottom() > magnet.Bottom()) {
356 offset.SetY(std::min(0.0, std::max(magnet.Top() - Top(), magnet.Bottom() - Bottom())));