android.graphics.Shader#getLocalMatrix ( )源码实例Demo

下面列出了android.graphics.Shader#getLocalMatrix ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: microMathematics   文件: SVGAndroidRenderer.java
@SuppressWarnings("deprecation")
private void  doStroke(Path path)
{
   // TODO handle degenerate subpaths properly

   if (state.style.vectorEffect == VectorEffect.NonScalingStroke)
   {
      // For non-scaling-stroke, the stroke width is not transformed along with the path.
      // It will be rendered at the same width no matter how the document contents are transformed.

      // First step: get the current canvas matrix
      Matrix  currentMatrix = canvas.getMatrix();
      // Transform the path using this transform
      Path  transformedPath = new Path();
      path.transform(currentMatrix, transformedPath);
      // Reset the current canvas transform completely
      canvas.setMatrix(new Matrix());

      // If there is a shader (such as a gradient), we need to update its transform also
      Shader  shader = state.strokePaint.getShader();
      Matrix  currentShaderMatrix = new Matrix();
      if (shader != null) {
         shader.getLocalMatrix(currentShaderMatrix);
         Matrix  newShaderMatrix = new Matrix(currentShaderMatrix);
         newShaderMatrix.postConcat(currentMatrix);
         shader.setLocalMatrix(newShaderMatrix);
      }

      // Render the transformed path. The stroke width used will be in unscaled device units.
      canvas.drawPath(transformedPath, state.strokePaint);

      // Return the current canvas transform to what it was before all this happened         
      canvas.setMatrix(currentMatrix);
      // And reset the shader matrix also
      if (shader != null)
         shader.setLocalMatrix(currentShaderMatrix);
   }
   else
   {
      canvas.drawPath(path, state.strokePaint);
   }
}
 
源代码2 项目: starcor.xul   文件: SVGAndroidRenderer.java
@SuppressWarnings("deprecation")
private void  doStroke(Path path)
{
   // TODO handle degenerate subpaths properly

   if (state.style.vectorEffect == VectorEffect.NonScalingStroke)
   {
      // For non-scaling-stroke, the stroke width is not transformed along with the path.
      // It will be rendered at the same width no matter how the document contents are transformed.

      // First step: get the current canvas matrix
      Matrix  currentMatrix = canvas.getMatrix();
      // Transform the path using this transform
      Path  transformedPath = new Path();
      path.transform(currentMatrix, transformedPath);
      // Reset the current canvas transform completely
      canvas.setMatrix(new Matrix());

      // If there is a shader (such as a gradient), we need to update its transform also
      Shader  shader = state.strokePaint.getShader();
      Matrix  currentShaderMatrix = new Matrix();
      if (shader != null) {
         shader.getLocalMatrix(currentShaderMatrix);
         Matrix  newShaderMatrix = new Matrix(currentShaderMatrix);
         newShaderMatrix.postConcat(currentMatrix);
         shader.setLocalMatrix(newShaderMatrix);
      }

      // Render the transformed path. The stroke width used will be in unscaled device units.
      canvas.drawPath(transformedPath, state.strokePaint);

      // Return the current canvas transform to what it was before all this happened         
      canvas.setMatrix(currentMatrix);
      // And reset the shader matrix also
      if (shader != null)
         shader.setLocalMatrix(currentShaderMatrix);
   }
   else
   {
      canvas.drawPath(path, state.strokePaint);
   }
}
 
源代码3 项目: XDroidAnimation   文件: SVGAndroidRenderer.java
@SuppressWarnings("deprecation")
private void  doStroke(Path path)
{
   // TODO handle degenerate subpaths properly

   if (state.style.vectorEffect == VectorEffect.NonScalingStroke)
   {
      // For non-scaling-stroke, the stroke width is not transformed along with the path.
      // It will be rendered at the same width no matter how the document contents are transformed.

      // First step: get the current canvas matrix
      Matrix  currentMatrix = canvas.getMatrix();
      // Transform the path using this transform
      Path  transformedPath = new Path();
      path.transform(currentMatrix, transformedPath);
      // Reset the current canvas transform completely
      canvas.setMatrix(new Matrix());

      // If there is a shader (such as a gradient), we need to update its transform also
      Shader  shader = state.strokePaint.getShader();
      Matrix  currentShaderMatrix = new Matrix();
      if (shader != null) {
         shader.getLocalMatrix(currentShaderMatrix);
         Matrix  newShaderMatrix = new Matrix(currentShaderMatrix);
         newShaderMatrix.postConcat(currentMatrix);
         shader.setLocalMatrix(newShaderMatrix);
      }

      // Render the transformed path. The stroke width used will be in unscaled device units.
      canvas.drawPath(transformedPath, state.strokePaint);

      // Return the current canvas transform to what it was before all this happened         
      canvas.setMatrix(currentMatrix);
      // And reset the shader matrix also
      if (shader != null)
         shader.setLocalMatrix(currentShaderMatrix);
   }
   else
   {
      canvas.drawPath(path, state.strokePaint);
   }
}