瀏覽代碼

********************************** *********************
添加矩阵,post 改为 pre

zhangweixin 3 年之前
父節點
當前提交
1d7ccf4bf4

+ 1 - 1
settings.gradle

@@ -20,7 +20,7 @@
  *
  * ********************************************************************************************************************
  */
-rootProject.name = 'saga-android'
+rootProject.name = 'saga-android-persagy'
 
 include ':sybotan-android-base'
 include ':sybotan-android-database'

+ 8 - 6
sybotan-android-graphy/src/main/java/com/sybotan/android/graphy/SGraphyItem.kt

@@ -62,9 +62,11 @@ open class SGraphyItem(parent: SGraphyItem? = null) {
          */
         fun toChildMotionEvent(child: SGraphyItem, e: SMotionEvent): SMotionEvent {
             val ce = SMotionEvent(e)
-            ce.matrix.postTranslate(child.pos.x, child.pos.y);
-            ce.matrix.postScale(child.scale.x, child.scale.y);
-            ce.matrix.postRotate(child.rotate,0f, 0f);
+            ce.matrix.preTranslate(child.pos.x, child.pos.y);
+            ce.matrix.preScale(child.scale.x, child.scale.y);
+            ce.matrix.preRotate(child.rotate,0f, 0f);
+
+
             // 不跟随缩放
             if (!child.isTransform) {
                 ce.matrix.postScale(child._inverseScale, child._inverseScale);
@@ -627,9 +629,9 @@ open class SGraphyItem(parent: SGraphyItem? = null) {
         val m = Matrix()
         val list = this.itemPath()
         for ( item in list) {
-            m.postTranslate(item.pos.x, item.pos.y);
-            m.postScale(item.scale.x, item.scale.y);
-            m.postRotate(item.rotate)
+            m.preTranslate(item.pos.x, item.pos.y);
+            m.preScale(item.scale.x, item.scale.y);
+            m.preRotate(item.rotate)
             // 如果不进行变形处理,则取消 painter 的变型操作
             if (!item.isTransform){
                 m.postScale(item._inverseScale, item._inverseScale);

+ 3 - 3
sybotan-android-graphy/src/main/java/com/sybotan/android/graphy/SGraphyScene.kt

@@ -313,9 +313,9 @@ open class SGraphyScene {
         val se = SMotionEvent(e)
         se.matrix = Matrix()
         if (this.view != null ){
-            se.matrix.postTranslate(this.view!!.pos.x, this.view!!.pos.y);
-            se.matrix.postScale(this.view!!.scale, this.view!!.scale)
-            se.matrix.postRotate(this.view!!.rotate)
+            se.matrix.preTranslate(this.view!!.pos.x, this.view!!.pos.y);
+            se.matrix.preScale(this.view!!.scale, this.view!!.scale)
+            se.matrix.preRotate(this.view!!.rotate)
         }
         se.matrix.postConcat(item.scene2itemMattrix())
         val matrix = Matrix()

+ 3 - 3
sybotan-android-graphy/src/main/java/com/sybotan/android/graphy/SGraphyView.kt

@@ -549,9 +549,9 @@ open class SGraphyView(context: Context, attrs: AttributeSet? = null)
         val src1 = kotlin.floatArrayOf(0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f)
         val src2 = kotlin.floatArrayOf(0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f)
         val se = SMotionEvent(e)
-        se.matrix.postTranslate(pos.x,pos.y)
-        se.matrix.postScale(this.scale, this.scale);
-        se.matrix.postRotate(this.rotate)
+        se.matrix.preTranslate(pos.x,pos.y)
+        se.matrix.preScale(this.scale, this.scale);
+        se.matrix.preRotate(this.rotate)
         se.matrix.getValues(src1)
         Log.e("src1= ",src1.toJson())