當前位置: 首頁>>代碼示例>>Java>>正文


Java Shader.getLocalMatrix方法代碼示例

本文整理匯總了Java中android.graphics.Shader.getLocalMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Java Shader.getLocalMatrix方法的具體用法?Java Shader.getLocalMatrix怎麽用?Java Shader.getLocalMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Shader的用法示例。


在下文中一共展示了Shader.getLocalMatrix方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doStroke

import android.graphics.Shader; //導入方法依賴的package包/類
@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);
	}
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:44,代碼來源:SVGAndroidRenderer.java


注:本文中的android.graphics.Shader.getLocalMatrix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。