Lines Matching defs:self

63 RAreaIsValid(const RArea *self)
65 return self->width >= 0 && self->height >= 0;
73 RAreaX2(const RArea *self)
75 return self->x + self->width - 1;
83 RAreaY2(const RArea *self)
85 return self->y + self->height - 1;
93 RAreaArea(const RArea *self)
95 return self->width * self->height;
103 RAreaIntersect(const RArea *self, const RArea *other)
106 if(RAreaIsIntersect(self, other)) {
109 x1 = max(other->x, self->x);
110 x2 = min(RAreaX2(other), RAreaX2(self));
112 y1 = max(other->y, self->y);
113 y2 = min(RAreaY2(other), RAreaY2(self));
127 RAreaIsIntersect(const RArea *self, const RArea *other)
129 // [other][self]
130 if(RAreaX2(other) < self->x) {
134 // [self][other]
135 if(other->x > RAreaX2(self)) {
140 // [self]
141 if(RAreaY2(other) < self->y) {
145 // [self]
147 if(other->y > RAreaY2(self)) {
159 RAreaContainsXY(const RArea *self, int x, int y)
161 return x >= self->x && x <= RAreaX2(self)
162 && y >= self->y && y <= RAreaY2(self);
179 RAreaHorizontalUnion(const RArea *self, const RArea *other)
183 // [other] [self] or [self] [other]
184 if(RAreaX2(other) < self->x - 1) {
187 if(other->x > RAreaX2(self) + 1) {
192 // [other] or [self]
193 // [self] [other]
194 if(RAreaY2(other) < self->y || other->y > RAreaY2(self)) {
198 if(self->width == other->width && self->x == other->x) {
200 // [self ]
201 if(RAreaY2(other) + 1 == self->y) {
204 RAreaNewStatic(self->x, other->y,
205 self->width, self->height + other->height),
209 // [self ]
211 if(RAreaY2(self) + 1 == other->y) {
214 RAreaNewStatic(self->x, self->y,
215 self->width, self->height + other->height),
232 const int min_x = min(self->x, other->x);
233 const int max_x = max(RAreaX2(self), RAreaX2(other));
240 if(self->y < other->y) {
241 top = self;
246 bot = self;
304 RAreaVerticalUnion(const RArea *self, const RArea *other)
307 if(RAreaY2(other) < self->y - 1) {
310 if(other->y > RAreaY2(self) + 1) {
315 // [other][self] or [self][other]
316 if(RAreaX2(other) < self->x || other->x > RAreaX2(self)) {
320 if(self->height == other->height && self->y == other->y) {
321 // [other][self]
322 if(RAreaX2(other) + 1 == self->x) {
325 RAreaNewStatic(other->x, self->y,
326 self->width + other->width, self->height),
330 // [self][other]
331 if(RAreaX2(self) + 1 == other->x) {
334 RAreaNewStatic(self->x, self->y,
335 self->width + other->width, self->height),
348 const int min_y = min(self->y, other->y);
349 const int max_y = max(RAreaY2(self), RAreaY2(other));
356 if(self->x < other->x) {
357 left = self;
362 right = self;
411 RAreaPrint(const RArea *self)
413 fprintf(stderr, "[x=%d y=%d w=%d h=%d]", self->x, self->y, self->width,
414 self->height);