Form.st
changeset 4206 4d3273b10f37
parent 4173 100ca435fb0e
child 4217 7786f64f5926
--- a/Form.st	Wed Jul 14 23:43:29 2004 +0200
+++ b/Form.st	Fri Jul 16 13:38:11 2004 +0200
@@ -1486,18 +1486,58 @@
 !
 
 flipHorizontal
-    "return a new form flipped horizontally"
-
-    |dstY newForm nRows "{ Class: SmallInteger }" |
+    "return a new form flipped vertically"
+
+    |dstX newForm |
 
     newForm := (self class onDevice:device)
                                 width:width
                                 height:height
                                 depth:depth.
-    "expand rows"
+    dstX := width - 1.
+    0 to:dstX do:[:srcX |
+        newForm copyFrom:self
+                       x:srcX y:0
+                     toX:dstX y:0
+                   width:1 height:height.
+        dstX := dstX - 1
+    ].
+    newForm colorMap:localColorMap.
+    ^ newForm
+
+    "
+     |testForm|
+
+     testForm _ Form 
+                    extent: 8@8 
+                    depth: 1 
+                    fromArray:
+                     #( 2r10000000
+                        2r11000000 
+                        2r11100000
+                        2r11110000 
+                        2r11111000
+                        2r11111100 
+                        2r11111110
+                        2r11111111)
+                    offset: 0@0.
+     testForm inspect.
+     testForm flipVertical inspect.
+     testForm flipHorizontal inspect.
+    "
+!
+
+flipVertical
+    "return a new form flipped horizontally"
+
+    |dstY newForm |
+
+    newForm := (self class onDevice:device)
+                                width:width
+                                height:height
+                                depth:depth.
     dstY := height - 1.
-    nRows := dstY // 2.
-    0 to:nRows do:[:srcY |
+    0 to:dstY do:[:srcY |
         newForm copyFrom:self
                        x:0 y:srcY
                      toX:0 y:dstY
@@ -1506,29 +1546,27 @@
     ].
     newForm colorMap:localColorMap.
     ^ newForm
-!
-
-flipVertical
-    "return a new form flipped vertically"
-
-    |dstX newForm nCols "{ Class: SmallInteger }" |
-
-    newForm := (self class onDevice:device)
-                                width:width
-                                height:height
-                                depth:depth.
-    "expand cols"
-    dstX := width - 1.
-    nCols := dstX // 2.
-    0 to:nCols do:[:srcX |
-        newForm copyFrom:self
-                       x:srcX y:0
-                     toX:dstX y:0
-                   width:1 height:height.
-        dstX := dstX - 1
-    ].
-    newForm colorMap:localColorMap.
-    ^ newForm
+
+    "
+     |testForm|
+
+     testForm _ Form 
+                    extent: 8@8 
+                    depth: 1 
+                    fromArray:
+                     #( 2r10000000
+                        2r11000000 
+                        2r11100000
+                        2r11110000 
+                        2r11111000
+                        2r11111100 
+                        2r11111110
+                        2r11111111)
+                    offset: 0@0.
+     testForm inspect.
+     testForm flipVertical inspect.
+     testForm flipHorizontal inspect.
+    "
 !
 
 hardMagnifiedBy:extent
@@ -2201,7 +2239,7 @@
 !Form class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Form.st,v 1.129 2004-05-11 16:44:44 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Form.st,v 1.130 2004-07-16 11:38:11 cg Exp $'
 ! !
 
 Form initialize!