/WJMagicCurveView

By simply setting several parameters, You'll get a fancy magic curve immediately.

Primary LanguageJava

WJMagicCurveView

By setting several parameters simply, You'll get a fancy Magic Curve immediately.

中文介绍,来自Android-CJJ同学

Let's see what it is

Order Demo
1
2
3
4
5

How it works

By setting eight parameters (Of course you don't have to set every because they all have default value), WJMagicCurveView will draw a beautiful curve based on a math function.

First, we'll create two points and make them rotate in specified speed and specified radius revolving a same center; Second, whenever they reach a point during rotating, we'll draw a line connecting these two points; Thirds, continue rotate and draw lines, Bingo! You're creating a new beautiful curve!

How to create your own curve

We provide eight base parameters for normal users and more for developers from code level. Here are explaintion for these parameters:

  1. radiusAXradiusAY: A point is the outer rotating point, these two are the radius of A;
  2. radiusBXradiusBY: B point is the inner rotating point;
  3. speedOuterPointspeedInnerPoint: the rotating speed for A & B;
  4. loopTotalCount: the loop count for these two rotating points;
  5. durationSeconds: the durationg speed for rotating.

Playable apk

Download it from here and make a try!

How to use it

WJMagicCurveView wjMagicCurveView = (WJMagicCurveView) findViewById(R.id.wj_magic_curve_view);
// set parameters. of course it's not necessary to set all these parameters because they all have default value
wjMagicCurveView.setRadius(radiusAX, radiusAY, radiusBX, radiusBY)
                .setDurationSec(durationSeconds)
                .setLoopTotalCount(loopTotalCount)
                .setSpeed(speedOuterPoint, speedInnerPoint)
                .startDraw();
// stop Draw
wjMagicCurveView.stopDraw();
// destory and recycle bitmap
wjMagicCurveView.destory();
// Customize your own curve here
I create a enum called WJMagicCurveViewParameters, 
You can create your own WJMagicCurveViewParameters with eight parameters,
for empty fields, use -1 as default value.

Related resource

有趣的曲线在Android上的实现

Processing: 简单法则的魅力

###Reach me - wingjay

You can get information about me and reach me in my github page: https://github.com/wingjay

Blog: https://wingjay.com

Weibo: http://weibo.com/u/1625892654

Feel free to give me advices by mailto:yinjiesh@126.com

Thanks!