Git Product home page Git Product logo

android_graphics_instance_one's Introduction

#Android的Graphics类绘制图形 (Canvas Paint Path) #(下面有效果图)

English Description

This Demo is through the Canvas on the Graphics class Adnroid, Paint, the Path to map the instance of project, for your reference

BaseAnimation QQ group:149581646

Author's blog: http://blog.csdn.net/duguang77

中文说明

这个Demo是通过Adnroid的Graphics类中的Canvas,Paint,Path绘制出的实例工程,供大家参考

BaseAnimation QQ群:149581646

作者博客:http://blog.csdn.net/duguang77

====

ScreenShot

Image . Image . Image

Image

这样拆分出来的图,大家就应该知道这张图示怎么画的吧! 我们来细讲一下,圆心点坐标我们通过 protected void onDraw(Canvas canvas) { super.onDraw(canvas); mWidth = canvas.getWidth(); mHeight = canvas.getHeight(); mCenterX = mWidth/2; mCenterY = mHeight/4; }

继承的View类 OnDraw()方法中的Canvas获取出屏幕一半宽,1/4高的点的位置,这就是上图中的O点坐标,而柱状体我们也是通过自己给的坐标点画出的,所以这两个点都是已知的。

我们最重要的是控制好过圆心,画出三角形, 我们通过之前了解到通过Canvas+Path+Paint组合API可以画出三角形,但是我们并不知道点P和P'的坐标位置,

//开始画三角形
	Path path = new Path();// 三角形
	
	
	path.moveTo((float)(x2), (float)(y2));//P点坐标
	path.lineTo((float)(mPointB.x), (float)(mPointB.y));//圆心点坐标
	path.lineTo((float)x1, (float)y1);//P'点坐标
	path.close();//闭合画笔路径
	canvas.drawPath(path, paint);//开始画

通过简化图,我们可以看出,其实就是一个数学问题,通过点O坐标和点H坐标,OP'和OP边长是自己给定的定值所以也是已知的,OH边长已知,PH和P'H通过勾三股四算出可得,有了这些参数我们就可以组成一个二元一次方程组来算出P和P'坐标如下所示

android_graphics_instance_one's People

Contributors

z56402344 avatar

Watchers

weiwu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.