GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 开启内圆的旋转 · tmexcept/AndroidCustomView@e94532c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main/java/com/allen/androidcustomview/widget
    • LuckyWheelAnimView.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/java/com/allen/androidcustomview/widget/LuckyWheelAnimView.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/widget/LuckyWheelAnimView.java
+18-19Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.allen.androidcustomview.widget;
22

33

4-
import android.animation.AnimatorSet;
5-
import android.animation.FloatEvaluator;
64
import android.animation.ValueAnimator;
75
import android.annotation.SuppressLint;
86
import android.content.Context;
@@ -19,8 +17,6 @@
1917
import android.util.Log;
2018
import android.view.MotionEvent;
2119
import android.view.View;
22-
import android.view.animation.AccelerateInterpolator;
23-
import android.view.animation.DecelerateInterpolator;
2420
import android.view.animation.LinearInterpolator;
2521

2622
import com.allen.androidcustomview.R;
@@ -140,7 +136,7 @@ private void initTextPaint() {
140136
private boolean isSmall;
141137
public void setSmall() {
142138
initBaseSize();
143-
isSmall = true;
139+
isSmall = false;
144140

145141
BitmapFactory.Options options = new BitmapFactory.Options();
146142
options.inPreferredConfig = Bitmap.Config.RGB_565;
@@ -170,10 +166,14 @@ public void setSmall() {
170166
angle = random.nextInt(57) - 28;
171167
awardNum = random.nextInt(6);
172168
angle = 360 + awardNum * 60 + angle;
173-
float spend = new BigDecimal(angle).divide(new BigDecimal(360), 2, BigDecimal.ROUND_UP).floatValue();
169+
float spend = new BigDecimal(angle)
170+
.divide(new BigDecimal(360), 2, RoundingMode.UP).floatValue();
174171
float time = spend + 1 + 2.5f;
175-
a = new BigDecimal(360).divide(new BigDecimal(spend), 2, BigDecimal.ROUND_UP).floatValue();
176-
Log.d("xijingLog", "time="+time+" "+awardNum);
172+
bigWheelAccent = new BigDecimal(360)
173+
.divide(new BigDecimal(spend), 2, RoundingMode.UP).floatValue();
174+
Log.d("xijingLog", "time="+time+" awardNum="+awardNum+" angle="+angle+" t="+spend);
175+
smallWheelSpeed = new BigDecimal(3*360)
176+
.divide(new BigDecimal(time - 1), 2, RoundingMode.UP).floatValue();
177177
anim.setFloatValues(0, time);
178178
anim.setDuration((long) (time * 1000));
179179

@@ -351,30 +351,29 @@ private void initAnim() {
351351
@Override
352352
public void onAnimationUpdate(ValueAnimator animation) {
353353
float t = (float) animation.getAnimatedValue();
354+
if(t >= 1){
355+
angleIn = (int) (smallWheelSpeed * (t - 1)) % 360;
356+
}
357+
// Log.e("xijingLog", "angleIn="+angleIn+" t="+t);
358+
354359
if(t <= 1) {
355360
t = (float)Math.pow(t, 2);
356361
angleOut = (int) (t * 360)/2;
357-
// Log.d("xijingLog", "111 angleOut ="+angleOut +" t="+t +" In="+angleIn);
358-
} else if(t <= 3.5f) {
359-
//360 / 1 * t
362+
} else if(t < 3.5f) {
360363
angleOut = (int) ((t - 1) * 360 + 180);
361-
// Log.d("xijingLog", "222 angleOut ="+angleOut +" t="+t +" In="+angleIn);
362364
} else {
363365
t = (t - 3.5f);
364-
// float v = (float) (1.0f - Math.pow((1.0f - t), 2 * 2));
365-
// float v = 360 - 360*t;
366-
angleOut = (int) (360 * t - (a * Math.pow(t, 2))/2);
367-
// Log.e("xijingLog", "t="+t+" v="+v);
368-
// angleOut = (int) (v * 360 * t);
369-
// Log.d("xijingLog", "333 angleOut ="+angleOut +" t="+t +" In="+angleIn);
366+
angleOut = (int) (360 * t - bigWheelAccent * Math.sqrt(t)/2);
367+
Log.e("xijingLog", "angleOut="+angleOut+" t="+t);
370368
}
371369

372370
angleOut %= 360;
373371
invalidate();
374372
}
375373
});
376374
}
377-
float a;
375+
float bigWheelAccent;//加速度
376+
float smallWheelSpeed;//小圆的速度
378377

379378
private RectF rectFTouch;
380379
private short downIndex;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.