Skip to content

Commit

Permalink
add CloverView
Browse files Browse the repository at this point in the history
  • Loading branch information
leeowenowen committed Aug 12, 2016
1 parent 0956901 commit 55c92cd
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ proguard/

.idea/

sw[owp]
*.sw[owp]
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,53 @@

demenstrate the beauty of math.


#多项式函数
#函数
##多项式函数
- 常函数
- 一次函数
- 二次函数
- 三次函数
- 四次函数
- 五次函数
#基本初等函数
##基本初等函数
- 幂函数
- 指数函数
- 对数函数
- 三角函数
- 反三角函数
#常用函数
##常用函数
- 实函数
- 双曲函数
- 隐函数
- 多元函数
- 其他
#复变函数
#程序函数
#完全函数
##复变函数
##程序函数
##完全函数

#方程类型
##直角坐标系方程
##极坐标方程
##参数方程


#曲线
##圆
##椭圆
##双曲线
##抛物线
##阿基米德螺旋曲线
##四叶草曲线
##克莱曲线


#漂亮曲线
##心形
###笛卡尔心形
###普通心形
###浪漫心形





53 changes: 53 additions & 0 deletions bom/src/main/java/owo/bom/CloverView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package owo.bom;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.Log;
import android.view.View;


public class CloverView extends View {
private Paint mPaint = new Paint();
Bitmap mMemBitmap;
private Canvas mMemCanvas;
private Path mPath = new Path();

public CloverView(Context context) {
super(context);
mPaint.setColor(Color.RED);
mPaint.setStrokeWidth(2);
mMemBitmap = Bitmap.createBitmap(800, 800, Bitmap.Config.ARGB_8888);
mMemCanvas = new Canvas(mMemBitmap);
}

/**
* x=sin(t)*sin(t)*cos(t)
* y=cos(t)*cos(t)*sin(t)
*/
private void drawHeart(Canvas canvas) {
mPath.reset();
double a = 400;
double t = 0;
double x = 400 + a * Math.sin(t) * Math.sin(t) * Math.cos(t);
double y = 400 + a * Math.cos(t) * Math.cos(t) * Math.sin(t);
mPath.moveTo((float) x, (float) y);
for (; t < 2 * Math.PI; t += 0.01) {
x = 400 + a * Math.sin(t) * Math.sin(t) * Math.cos(t);
y = 400 + a * Math.cos(t) * Math.cos(t) * Math.sin(t);
mPath.lineTo((float) x, (float) y);
Log.d("XXX", "" + x + ":" + y);
}
canvas.drawPath(mPath, mPaint);
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawHeart(mMemCanvas);
canvas.drawBitmap(mMemBitmap, 0, 0, null);
}
}
3 changes: 2 additions & 1 deletion demo/src/main/java/com/owo/bom/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import owo.bom.CloverView;
import owo.bom.HeartView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HeartView view = new HeartView(this);
CloverView view = new CloverView(this);
view.setBackgroundColor(Color.GREEN);
setContentView(view);
}
Expand Down
Binary file added img/heart_dikaer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/heart_normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/heart_romantic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 55c92cd

Please sign in to comment.