on a scale of 0 to awesome, I count this as AWESOME
authorRichard Fairhurst <richard@systemed.net>
Sun, 28 Nov 2010 20:00:45 +0000 (20:00 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 28 Nov 2010 20:00:45 +0000 (20:00 +0000)
net/systemeD/halcyon/Map.as
net/systemeD/halcyon/TileSet.as
net/systemeD/potlatch2/BackgroundSelector.mxml

index 973878f..103caba 100644 (file)
@@ -375,6 +375,10 @@ package net.systemeD.halcyon {
                        if (tileset) { tileset.setDimming(dim); }
                }
 
+               public function setSharpen(sharpen:Boolean):void {
+                       if (tileset) { tileset.setSharpen(sharpen); }
+               }
+
                // ------------------------------------------------------------------------------------------
                // Export (experimental)
                // ** just a bit of fun for now!
index 9f829fa..d35e713 100644 (file)
@@ -5,6 +5,7 @@ package net.systemeD.halcyon {
        import flash.net.*;
        import flash.system.LoaderContext;
        import flash.utils.Timer;
+       import flash.filters.*;
        import net.systemeD.halcyon.MapEvent;
 
     public class TileSet extends Sprite {
@@ -25,6 +26,12 @@ package net.systemeD.halcyon {
 
                private var map:Map;
 
+               private var sharpenFilter:BitmapFilter = new ConvolutionFilter(3, 3, 
+                       [0, -1, 0,
+            -1, 5, -1,
+             0, -1, 0], 0);
+               private var sharpening:Boolean = false;
+               // http://flylib.com/books/en/2.701.1.170/1/
 
         public function TileSet(map:Map) {
                        this.map=map;
@@ -53,6 +60,17 @@ package net.systemeD.halcyon {
                        alpha=dim ? 0.5 : 1;
                }
 
+               public function setSharpen(sharpen:Boolean):void {
+                       var f:Array=[]; if (sharpen) { f=[sharpenFilter]; }
+                       for (var i:uint=0; i<numChildren; i++) {
+                               var s:Sprite=Sprite(getChildAt(i));
+                               for (var j:uint=0; j<s.numChildren; j++) {
+                                       s.getChildAt(j).filters=f;
+                               }
+                       }
+                       sharpening=sharpen;
+               }
+
                public function changeScale(scale:uint):void {
                        for (var i:uint=map.MINSCALE; i<=map.MAXSCALE; i++) {
                                this.getChildAt(i-map.MINSCALE).visible=(scale==i);
@@ -103,6 +121,7 @@ package net.systemeD.halcyon {
                                        Sprite(l).addChild(loader);
                                        loader.x=map.lon2coord(tile2lon(tx));
                                        loader.y=map.lat2coord(tile2lat(ty));
+                                       if (sharpening) { loader.filters=[sharpenFilter]; }
 //                                     loader.alpha=0.5;
                                }
                        }
index d7363db..c2892bb 100644 (file)
@@ -8,8 +8,12 @@
                        labelField="name"
                        change="Application.application.bgButton.close(); Application.application.setBackground(background.selectedItem);"                      
                dataProvider="{Application.application.getAvailableImagery()}" />
-       <mx:CheckBox width="100%" label="Dim background" selected="true" id="dim"
+       <mx:HBox>
+       <mx:CheckBox width="100%" label="Dim" selected="true" id="dim"
            change="Application.application.theMap.setDimming(dim.selected); Application.application.yahoo.alpha = dim.selected ? 0.5 : 1" />
+       <mx:CheckBox width="100%" label="Sharpen" selected="false" id="sharpen"
+           change="Application.application.theMap.setSharpen(sharpen.selected);" />
+       </mx:HBox>
 
        <mx:HBox>
        <mx:Button label="Edit..." click="Application.application.bgButton.close(); new BackgroundDialog().init('Background imagery',background,Application.application.theController.imagery);" />