Revision: 4751
          http://sourceforge.net/p/vexi/code/4751
Author:   mkpg2
Date:     2014-11-23 17:44:34 +0000 (Sun, 23 Nov 2014)
Log Message:
-----------
Canvas.clear().

Modified Paths:
--------------
    branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java
    branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t

Modified: 
branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java
===================================================================
--- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java   
2014-11-23 17:22:58 UTC (rev 4750)
+++ branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Canvas.java   
2014-11-23 17:44:34 UTC (rev 4751)
@@ -1,5 +1,6 @@
 package org.vexi.core;
 
+import java.awt.AlphaComposite;
 import java.awt.BasicStroke;
 import java.awt.Graphics2D;
 import java.awt.Image;
@@ -52,12 +53,13 @@
        @Override public JS get(JS name) throws JSExn {
                String nameStr = JSU.toString(name);
                if("drawLine".equals(nameStr)) return METHOD;           
+               if("clear".equals(nameStr)) return METHOD;              
+               if("load".equals(nameStr)) return METHOD;
+               if("save".equals(nameStr)) return METHOD;
                if("drawColor".equals(nameStr)) return 
JSU.S(Color.colorToString(drawColor));           
                if("drawWidth".equals(nameStr)) return JSU.N(strokeWidth);
                if("antialias".equals(nameStr)) return JSU.B(antialias);
                if("dotsPerPixel".equals(nameStr)) return JSU.N(dotsPerPixel);
-               if("load".equals(nameStr)) return METHOD;
-               if("save".equals(nameStr)) return METHOD;
                return super.get(name);
        }
        
@@ -103,6 +105,13 @@
                dirty();
 //                     dirty(this, x1-1,y1-1,x2+1,y2+1);
                        return null;            
+               }else if("clear".equals(nameStr)) {
+                       Graphics2D g2 = (Graphics2D)getBuffer().getGraphics();
+                       
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
+                       g2.fillRect(0,0,getBuffer().getWidth(), 
getBuffer().getHeight());
+                       
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));           
        
+                       dirty();
+                       return null;
                }else if("save".equals(nameStr)){
                        String format = JSU.expectArg_string(args, 0);
                        return getStream(format);

Modified: branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t
===================================================================
--- branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t       
2014-11-23 17:22:58 UTC (rev 4750)
+++ branches/vexi3/org.vexi-vexi.demo/src_poke/poke/core/canvas.t       
2014-11-23 17:44:34 UTC (rev 4751)
@@ -12,6 +12,7 @@
                        height="400"
                        backgroundFill=":image.block_mask_20x20"/>
         <ui:Box height="50">
+            <w:button text="Clear" id="clear"/>            
             <w:button text="Save" id="save"/>            
             <w:button text="Load" id="load"/>
             <w:button text="Load Background" id="loadbg"/>
@@ -19,6 +20,10 @@
         
         var suffix = "png";
                 
+        $clear.action ++= function(v){
+            $draw.canvas.clear();
+        };        
+                
         $save.action ++= function(v){
             vexi.thread = function(){
                 var file = vexi.file.save("canvas."+suffix);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to