Incidentally, I don't know if it's common knowledge or not, but if you do this:
i = 0;
do
i++
plot_pixel(sin(i), cos(i));
loop
It draws a circle. Although it works better if you increment i by very small values, it's all good. I learned that a long long time ago when I was playing with QBasic graphics. By plotting SIN and COS against each other I used to draw spirals and waves and circles and stuff.
Quote from: iago on April 21, 2006, 08:25:23 PM
Incidentally, I don't know if it's common knowledge or not, but if you do this:
i = 0;
do
i++
plot_pixel(sin(i), cos(i));
loop
It draws a circle. Although it works better if you increment i by very small values, it's all good. I learned that a long long time ago when I was playing with QBasic graphics. By plotting SIN and COS against each other I used to draw spirals and waves and circles and stuff.
import java.awt.*;
import javax.swing.*;
/**
This class demonstrates drawing a circle by using the point {sin(i), cos(i)}
@author William LaFrance
@date 22 April 2006
*/
public class DrawCircle extends JFrame
{
/**
Program entry-point<br />
Calls class constructor
@param args Command-line arguments, split by spaces
*/
public static void main(String args[])
{
new DrawCircle();
}
/**
Class constructor<br />
Creates JFrame object and initalizes it
*/
private DrawCircle()
{
super("Circle Thing!");
this.setSize(1000, 1000);
this.getContentPane().setBackground(Color.black);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
/**
Draws the circle on the JFrame
@param g Graphics object to use for drawing on the JFrame
*/
public void paint(Graphics g)
{
g.setColor(Color.yellow);
for (double i = 1; i < 100; i+=0.05)
{
g.fillRect((int)(Math.sin(i)*450)+500, (int)(Math.cos(i)*450)+500, 2, 2);
}
}
}
Cool!
Quote from: iago on April 21, 2006, 08:25:23 PM
Incidentally, I don't know if it's common knowledge or not, but if you do this:
i = 0;
do
i++
plot_pixel(sin(i), cos(i));
loop
It draws a circle. Although it works better if you increment i by very small values, it's all good. I learned that a long long time ago when I was playing with QBasic graphics. By plotting SIN and COS against each other I used to draw spirals and waves and circles and stuff.
Welcome to being bored in high school with your first TI graphing calculator :-P
Hahaha:
public void DrawCircle(Color outlineColor, Point center, int radius, Image target)
{
using (Graphics g = Graphics.FromImage(target))
{
g.DrawEllipse(new Pen(new SolidBrush(outlineColor)),
center.X - radius,
center.Y - radius,
center.X + radius,
center.Y + radius);
}
}
<3 library methods. ;)
If you want to draw a circle, why not do x^2+y^2=r^2?
Quote from: unTactical on April 22, 2006, 02:17:43 PM
Quote from: iago on April 21, 2006, 08:25:23 PM
Incidentally, I don't know if it's common knowledge or not, but if you do this:
i = 0;
do
i++
plot_pixel(sin(i), cos(i));
loop
It draws a circle. Although it works better if you increment i by very small values, it's all good. I learned that a long long time ago when I was playing with QBasic graphics. By plotting SIN and COS against each other I used to draw spirals and waves and circles and stuff.
Welcome to being bored in high school with your first TI graphing calculator :-P
Amen, brothah.