𝗙𝗥𝗘𝗘 𝗦𝗪𝗕 𝗣𝗥𝗢𝗝𝗘𝗖𝗧
Ir al canal en Telegram
ᴘ@ɴᴇʟ ᴍᴀᴋɪɴɢ ɪɴ ꜱᴋᴇᴛᴄʜᴡᴀʀᴇ
Mostrar másEl país no está especificadoLa categoría no está especificada
1 020
Suscriptores
-124 horas
+107 días
+5630 días
Archivo de publicaciones
1 019
int currentColor = ring.getColor();
float currentRadius = ring.baseRadius * ring.z;
float strokeWidth = 3.5f + 5f * ring.z;
// হালকা ট্রেইল / নিয়ন টিউব শ্যাডো
float tailX = ring.x - (ring.vx * 9f);
float tailY = ring.y - (ring.vy * 9f);
android.graphics.LinearGradient gradient = new android.graphics.LinearGradient(
ring.x, ring.y, tailX, tailY,
new int[]{currentColor, android.graphics.Color.TRANSPARENT},
null,
android.graphics.Shader.TileMode.CLAMP
);
tubePaint.setShader(gradient);
tubePaint.setStrokeWidth(currentRadius * 1.7f);
canvas.drawLine(ring.x, ring.y, tailX, tailY, tubePaint);
// লাইভ আরজিবি রিং আঁকা
ringPaint.setColor(currentColor);
ringPaint.setStrokeWidth(strokeWidth);
canvas.drawCircle(ring.x, ring.y, currentRadius, ringPaint);
}
postInvalidateOnAnimation();
}
};
linear1.removeAllViews();
linear1.addView(animView, new android.widget.LinearLayout.LayoutParams(
android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
android.widget.LinearLayout.LayoutParams.MATCH_PARENT
));
1 019
অ্যানিমেশন কোড
animation code
final int totalRings = 32; // বলের সংখ্যা
final java.util.Random rand = new java.util.Random();
class RGBRing {
float x, y, z;
float vx, vy;
float baseRadius;
float hue; // RGB কালারের জন্য Hue ভ্যালু
int state; // 0 = সেন্টারে যাওয়া, 1 = ছড়িয়ে পড়া ও বাউন্স করা
int corner;
int bounceCount;
RGBRing(int w, int h, int cornerIndex) {
this.corner = cornerIndex;
reset(w, h);
}
void reset(int w, int h) {
z = 0.35f + rand.nextFloat() * 0.65f; // ৩ডি সাইজ পার্থক্য
baseRadius = 16f + rand.nextFloat() * 24f;
hue = rand.nextFloat() * 360f; // র্যান্ডম আরজিবি কালার থেকে শুরু
state = 0;
bounceCount = 0;
// ৪ কর্নার থেকে বের হওয়ার পজিশন
if (corner == 0) { x = -40; y = -40; } // Top-Left
else if (corner == 1) { x = w + 40; y = -40; } // Top-Right
else if (corner == 2) { x = -40; y = h + 40; } // Bottom-Left
else { x = w + 40; y = h + 40; } // Bottom-Right
// সেন্টারের দিকে যাওয়ার গতি (স্পিড কমিয়ে ধীর করা হয়েছে)
float cx = w / 2f;
float cy = h / 2f;
float dx = cx - x;
float dy = cy - y;
float dist = (float) Math.hypot(dx, dy);
float speed = (2.2f + rand.nextFloat() * 2.0f) * z;
vx = (dx / dist) * speed;
vy = (dy / dist) * speed;
}
void update(int w, int h) {
// ১. ক্রমাগত RGB রঙ পরিবর্তন (Hue shifting)
hue = (hue + 1.5f) % 360f;
x += vx;
y += vy;
float radius = baseRadius * z;
float cx = w / 2f;
float cy = h / 2f;
// ২. মাঝখানে পৌঁছালে চারদিকে ছিটকে পড়া
if (state == 0) {
float distToCenter = (float) Math.hypot(cx - x, cy - y);
if (distToCenter < 50f) {
state = 1;
float angle = rand.nextFloat() * (float)(2 * Math.PI);
float explodeSpeed = (2.8f + rand.nextFloat() * 2.5f) * z;
vx = (float) Math.cos(angle) * explodeSpeed;
vy = (float) Math.sin(angle) * explodeSpeed;
}
} else {
// ৩. চার দেয়ালে ধাক্কা খেয়ে বাউন্স
if (x - radius < 0) { x = radius; vx = -vx; bounceCount++; }
else if (x + radius > w) { x = w - radius; vx = -vx; bounceCount++; }
if (y - radius < 0) { y = radius; vy = -vy; bounceCount++; }
else if (y + radius > h) { y = h - radius; vy = -vy; bounceCount++; }
// বেশ কয়েকটি বাউন্সের পর আবার কর্নারে রিসেট
if (bounceCount > 6) {
reset(w, h);
}
}
}
int getColor() {
return android.graphics.Color.HSVToColor(new float[]{hue, 1.0f, 1.0f});
}
}
final android.graphics.Paint ringPaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);
ringPaint.setStyle(android.graphics.Paint.Style.STROKE);
final android.graphics.Paint tubePaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);
tubePaint.setStyle(android.graphics.Paint.Style.STROKE);
android.view.View animView = new android.view.View(this) {
private boolean initialized = false;
private final java.util.List<RGBRing> ringList = new java.util.ArrayList<>();
private void init(int w, int h) {
ringList.clear();
for (int i = 0; i < totalRings; i++) {
ringList.add(new RGBRing(w, h, i % 4));
}
initialized = true;
}
@Override
protected void onDraw(android.graphics.Canvas canvas) {
super.onDraw(canvas);
int width = getWidth();
int height = getHeight();
if (width <= 0 || height <= 0) return;
if (!initialized) {
init(width, height);
}
// ডার্ক ব্যাকগ্রাউন্ড
canvas.drawColor(android.graphics.Color.parseColor("#050508"));
for (RGBRing ring : ringList) {
ring.update(width, height);
