[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src/video _clip_rectangle
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src/video _clip_rectangle |
Date: |
Sun, 28 Sep 2003 17:19:16 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/09/28 17:19:15
Modified files:
src/video : _clip_rectangle
Log message:
Cleanup
Patches:
Index: stratagus/src/video/_clip_rectangle
diff -u stratagus/src/video/_clip_rectangle:1.9
stratagus/src/video/_clip_rectangle:1.10
--- stratagus/src/video/_clip_rectangle:1.9 Fri Jul 11 10:35:34 2003
+++ stratagus/src/video/_clip_rectangle Sun Sep 28 17:19:15 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: _clip_rectangle,v 1.9 2003/07/11 14:35:34 n0body Exp $
+// $Id: _clip_rectangle,v 1.10 2003/09/28 21:19:15 jsalmon3 Exp $
//@{
@@ -104,72 +104,76 @@
** }
*/
{
- int f, left, right, top, bottom;
-
-// Ensure non-empty rectangle
- if ( !(_w && _h ) ) {
- return; // rectangle is `void'
- }
-
-// Clip rectangle boundary
- left=right=top=bottom=1;
-
- if( _x<ClipX1 ) { // no left side
- f=ClipX1-_x;
- if ( _w<=f ) {
- return; // entire rectangle left --> not visible
- }
- _w-=f;
- _x=ClipX1;
- left=0;
- }
- if( (_x+_w)>ClipX2+1 ) { // no right side
- if( _x>ClipX2 ) {
- return; // entire rectangle right --> not visible
- }
- _w=ClipX2-_x+1;
- right=0;
- }
- if( _y<ClipY1 ) { // no top
- f=ClipY1-_y;
- if( _h<=f ) {
- return; // entire rectangle above --> not visible
- }
- _h-=f;
- _y=ClipY1;
- top=0;
- }
- if( (_y+_h)>ClipY2+1 ) { // no bottom
- if( _y>ClipY2 ) {
- return; // entire rectangle below --> not visible
- }
- _h=ClipY2-_y+1;
- bottom=0;
- }
-
-// Draw (part of) rectangle sides
-// Note: _hline and _vline should be able to handle zero width/height
- if ( top ) {
- _hline(_x,_y,_w);
- if ( ! --_h ) {
- return; // rectangle as horizontal line
- }
- _y++;
- }
- if ( bottom ) {
- _hline(_x,_y+_h-1,_w);
- _h--;
- }
- if ( left ) {
- _vline(_x,_y,_h);
- if ( ! --_w ) {
- return; // rectangle as vertical line
- }
- _x++;
- }
- if ( right ) {
- _vline(_x+_w-1,_y,_h);
- }
+ int f;
+ int left;
+ int right;
+ int top;
+ int bottom;
+
+ // Ensure non-empty rectangle
+ if (!(_w && _h)) {
+ return; // rectangle is `void'
+ }
+
+ // Clip rectangle boundary
+ left = right = top = bottom = 1;
+
+ if (_x < ClipX1) { // no left side
+ f = ClipX1 - _x;
+ if (_w <= f) {
+ return; // entire rectangle left -->
not visible
+ }
+ _w -= f;
+ _x = ClipX1;
+ left = 0;
+ }
+ if ((_x + _w) > ClipX2 + 1) { // no right side
+ if (_x > ClipX2) {
+ return; // entire rectangle right
--> not visible
+ }
+ _w = ClipX2 - _x + 1;
+ right = 0;
+ }
+ if (_y < ClipY1) { // no top
+ f = ClipY1 - _y;
+ if (_h <= f) {
+ return; // entire rectangle above
--> not visible
+ }
+ _h -= f;
+ _y = ClipY1;
+ top = 0;
+ }
+ if ((_y + _h) > ClipY2 + 1) { // no bottom
+ if (_y > ClipY2) {
+ return; // entire rectangle below -->
not visible
+ }
+ _h = ClipY2 - _y + 1;
+ bottom = 0;
+ }
+
+ // Draw (part of) rectangle sides
+ // Note: _hline and _vline should be able to handle zero width/height
+ if (top) {
+ _hline(_x, _y, _w);
+ if (!--_h) {
+ return; // rectangle as horizontal
line
+ }
+ ++_y;
+ }
+ if (bottom) {
+ _hline(_x, _y + _h - 1, _w);
+ --_h;
+ }
+ if (left) {
+ _vline(_x, _y, _h);
+ if (!--_w) {
+ return; // rectangle as vertical line
+ }
+ ++_x;
+ }
+ if (right) {
+ _vline(_x + _w - 1, _y, _h);
+ }
}
//@}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src/video _clip_rectangle,
Jimmy Salmon <=