السلام عليكــم ورحمـة الله وبركاتــه ،،
اجتاج الى كود رسم الدائرة باستخدام g.drawLine
يعني لا اريد رسمها باستخدام drawArc
بل عن طريق كود كامل وloops
و شكرا
السلام عليكــم ورحمـة الله وبركاتــه ،،
اجتاج الى كود رسم الدائرة باستخدام g.drawLine
يعني لا اريد رسمها باستخدام drawArc
بل عن طريق كود كامل وloops
و شكرا
صدقا ما بعرف اصلا قوانين الدائرة في الرياضيات
فارجو وضعها و منها ان شاء الله ابدأ
تحياتي اخ محمد
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
public class BouncingCircle extends Applet implements Runnable {
int x = 150, y = 50, r = 50;
int dx = 11, dy = 7; // Trajectory of circle
Thread animator;
volatile boolean pleaseStop;
public void paint(Graphics g) {
g.setColor(Color.red);
g.fillOval(x - r, y - r, r * 2, r * 2);
}
public void animate() {
Rectangle bounds = getBounds();
if ((x - r + dx < 0) || (x + r + dx > bounds.width))
dx = -dx;
if ((y - r + dy < 0) || (y + r + dy > bounds.height))
dy = -dy;
// move the circle.
x += dx;
y += dy;
repaint();
}
public void run() {
while (!pleaseStop) { // Loop until we're asked to stop
animate();
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
}
}
}
public void start() {
animator = new Thread(this);
pleaseStop = false;
animator.start();
}
public void stop() {
pleaseStop = true;
}
}هذا يعطيك خيارات جيدة للرسم مع امكانية الاعادة بالرسم
ماذا تقصد بقوانين الدائرة هل هي التي معتادين عليها ام هناك شئ جديد ؟
بالتوفيق
الله معك
السلام عليكــم ورحمـة الله وبركاتــه ،،
إستخدم معادلة الدائرة
اقتباسthe circle with center (a, b ) and radius r is the set of all points (x, y) such thatx = a + r * cos(t)
y = b + r * sin(t)
where t is a parametric variable, interpreted geometrically as the angle that the ray from the origin to (x, y) makes with the x-axis.
وهذا مثال لرسم دائرة باستعمال drawLine فقط
import java.awt.*;
المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية
جارٍ التحقق من المتواجدين…