You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ta...@apache.org on 2017/06/30 08:10:32 UTC

incubator-weex git commit: * [example] update gcanvas version and example

Repository: incubator-weex
Updated Branches:
  refs/heads/0.15-dev db640768c -> 55ba49624


* [example] update gcanvas version and example


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/55ba4962
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/55ba4962
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/55ba4962

Branch: refs/heads/0.15-dev
Commit: 55ba49624b7d1de7c125464222b488fead5bc4aa
Parents: db64076
Author: jwxbond <jw...@gmail.com>
Authored: Fri Jun 30 16:04:45 2017 +0800
Committer: jwxbond <jw...@gmail.com>
Committed: Fri Jun 30 16:04:45 2017 +0800

----------------------------------------------------------------------
 examples/vue/market/gcanvas.vue | 36 ++++++++++++++++--------------------
 package.json                    |  2 +-
 2 files changed, 17 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/55ba4962/examples/vue/market/gcanvas.vue
----------------------------------------------------------------------
diff --git a/examples/vue/market/gcanvas.vue b/examples/vue/market/gcanvas.vue
index 091a803..4bb1a1c 100644
--- a/examples/vue/market/gcanvas.vue
+++ b/examples/vue/market/gcanvas.vue
@@ -6,35 +6,31 @@
 <script>
   //	var gcanvas = weex.requireModule('weex-gcanvas');
 
-  var gcanvas=require('weex-gcanvas');
-
+  var GCanvas=require('weex-gcanvas');
+  var Image=require('weex-gcanvas/gcanvasimage');
 
   module.exports = {
-
-    created: function () {
-      console.log('created gcanvas');
-      gcanvas.disable();
-    },
     mounted: function () {
       var ref = this.$refs.canvas_holder;
-      gcanvas.start(ref, function () {
-        var ctx = gcanvas.getContext('2d');
+      var gcanvas = GCanvas.start(ref)
+      var ctx = gcanvas.getContext('2d');
 
-        ctx.fillStyle = 'red';
-        ctx.fillRect(0, 0, 100, 100);
+      ctx.fillStyle = 'red';
+      ctx.fillRect(0, 0, 100, 100);
 
-        ctx.fillStyle = 'black';
-        ctx.fillRect(100, 100, 100, 100);
-        ctx.fillRect(25, 210, 700, 5);
+      ctx.fillStyle = 'black';
+      ctx.fillRect(100, 100, 100, 100);
+      ctx.fillRect(25, 210, 700, 5);
 
-        ctx.arc(450, 200, 100, 0, Math.PI * 2, true);
-        ctx.fill();
+      ctx.arc(450, 200, 100, 0, Math.PI * 2, true);
+      ctx.fill();
 
-        var img = 'https://img.alicdn.com/tps/TB1TFNdKVXXXXbeaXXXXXXXXXXX-210-330.png';
+      var img = new Image();
+      img.onload = function(){
         ctx.drawImage(img, 100, 200, 210, 330);
-        //ctx.drawImage(img, 0,0,105,165, 100, 200, 210, 330);
-        ctx.render();
-      });
+        // ctx.drawImage(img, 0,0,105,165, 100, 200, 210, 330);
+      };
+      img.src = 'https://img.alicdn.com/tps/TB1TFNdKVXXXXbeaXXXXXXXXXXX-210-330.png';
     }
   };
 </script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/55ba4962/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 0a9e951..431deb9 100644
--- a/package.json
+++ b/package.json
@@ -159,7 +159,7 @@
     "vue-template-compiler": "^2.2.6",
     "webpack": "^1.13.1",
     "weex-components": "^0.2.0",
-    "weex-gcanvas": "^0.3.5",
+    "weex-gcanvas": "^0.4.2",
     "weex-loader": "^0.4.0",
     "weex-vdom-tester": "^0.2.0",
     "weex-wd": "^1.0.23",