Skip to content

Commit 18f4617

Browse files
committed
Rect: Rename intersection() to intersected()
1 parent 73795b0 commit 18f4617

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

include/scratchcpp/rect.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class LIBSCRATCHCPP_EXPORT Rect
3838
bool intersects(const Rect &rect) const;
3939
bool contains(double x, double y) const;
4040

41-
static void intersection(const Rect &a, const Rect &b, Rect &dst);
41+
static void intersected(const Rect &a, const Rect &b, Rect &dst);
4242
static void united(const Rect &a, const Rect &b, Rect &dst);
4343

4444
private:

src/rect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ bool Rect::contains(double x, double y) const
139139
}
140140

141141
/*! Saves the intersection of the given rectangles (in Scratch space) to dst. */
142-
void Rect::intersection(const Rect &a, const Rect &b, Rect &dst)
142+
void Rect::intersected(const Rect &a, const Rect &b, Rect &dst)
143143
{
144144
dst.impl->left = std::max(a.impl->left, b.impl->left);
145145
dst.impl->right = std::min(a.impl->right, b.impl->right);

test/rect/rect_test.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,12 @@ TEST(RectTest, Contains)
335335
ASSERT_TRUE(rect_ydown.contains(5, 24));
336336
}
337337

338-
TEST(RectTest, Intersection)
338+
TEST(RectTest, Intersected)
339339
{
340340
Rect rect1(-50, 25, 150, -75);
341341
Rect dst;
342342

343-
Rect::intersection(rect1, rect1, dst);
343+
Rect::intersected(rect1, rect1, dst);
344344
ASSERT_EQ(dst.left(), rect1.left());
345345
ASSERT_EQ(dst.top(), rect1.top());
346346
ASSERT_EQ(dst.right(), rect1.right());
@@ -349,7 +349,7 @@ TEST(RectTest, Intersection)
349349
// left
350350
{
351351
Rect rect2(-75, 0, 125, -50);
352-
Rect::intersection(rect1, rect2, dst);
352+
Rect::intersected(rect1, rect2, dst);
353353
ASSERT_EQ(dst.left(), -50);
354354
ASSERT_EQ(dst.top(), 0);
355355
ASSERT_EQ(dst.right(), 125);
@@ -358,7 +358,7 @@ TEST(RectTest, Intersection)
358358

359359
{
360360
Rect rect2(-100, 10, -50, -90);
361-
Rect::intersection(rect1, rect2, dst);
361+
Rect::intersected(rect1, rect2, dst);
362362
ASSERT_EQ(dst.left(), -50);
363363
ASSERT_EQ(dst.top(), 10);
364364
ASSERT_EQ(dst.right(), -50);
@@ -368,7 +368,7 @@ TEST(RectTest, Intersection)
368368
// top
369369
{
370370
Rect rect2(-25, 50, 125, 10);
371-
Rect::intersection(rect1, rect2, dst);
371+
Rect::intersected(rect1, rect2, dst);
372372
ASSERT_EQ(dst.left(), -25);
373373
ASSERT_EQ(dst.top(), 25);
374374
ASSERT_EQ(dst.right(), 125);
@@ -377,7 +377,7 @@ TEST(RectTest, Intersection)
377377

378378
{
379379
Rect rect2(-100, 50, 200, 25);
380-
Rect::intersection(rect1, rect2, dst);
380+
Rect::intersected(rect1, rect2, dst);
381381
ASSERT_EQ(dst.left(), -50);
382382
ASSERT_EQ(dst.top(), 25);
383383
ASSERT_EQ(dst.right(), 150);
@@ -387,7 +387,7 @@ TEST(RectTest, Intersection)
387387
// right
388388
{
389389
Rect rect2(125, 0, 200, -50);
390-
Rect::intersection(rect1, rect2, dst);
390+
Rect::intersected(rect1, rect2, dst);
391391
ASSERT_EQ(dst.left(), 125);
392392
ASSERT_EQ(dst.top(), 0);
393393
ASSERT_EQ(dst.right(), 150);
@@ -396,7 +396,7 @@ TEST(RectTest, Intersection)
396396

397397
{
398398
Rect rect2(150, 10, 200, -90);
399-
Rect::intersection(rect1, rect2, dst);
399+
Rect::intersected(rect1, rect2, dst);
400400
ASSERT_EQ(dst.left(), 150);
401401
ASSERT_EQ(dst.top(), 10);
402402
ASSERT_EQ(dst.right(), 150);
@@ -406,7 +406,7 @@ TEST(RectTest, Intersection)
406406
// bottom
407407
{
408408
Rect rect2(-25, -50, 125, -100);
409-
Rect::intersection(rect1, rect2, dst);
409+
Rect::intersected(rect1, rect2, dst);
410410
ASSERT_EQ(dst.left(), -25);
411411
ASSERT_EQ(dst.top(), -50);
412412
ASSERT_EQ(dst.right(), 125);
@@ -415,7 +415,7 @@ TEST(RectTest, Intersection)
415415

416416
{
417417
Rect rect2(-100, -75, 200, -100);
418-
Rect::intersection(rect1, rect2, dst);
418+
Rect::intersected(rect1, rect2, dst);
419419
ASSERT_EQ(dst.left(), -50);
420420
ASSERT_EQ(dst.top(), -75);
421421
ASSERT_EQ(dst.right(), 150);

0 commit comments

Comments
 (0)