Bitmap/Bresenham's line algorithm: Difference between revisions

Content added Content deleted
m (→‎{{header|C++}}: Formatted code, no functional changes)
m (→‎{{header|Java}}: small changes)
Line 1,283: Line 1,283:


public class Bresenham extends JFrame {
public class Bresenham extends JFrame {

BresenhamPanel panel;


public static void main(String[] args) {
public static void main(String[] args) {
Line 1,293: Line 1,291:


public Bresenham() {
public Bresenham() {
add(new BresenhamPanel(), BorderLayout.CENTER);
Container content = getContentPane();
content.setLayout(new BorderLayout());
panel = new BresenhamPanel();
content.add(panel, BorderLayout.CENTER);
setTitle("Bresenham");
setTitle("Bresenham");
pack();
pack();
Line 1,304: Line 1,299:


class BresenhamPanel extends JPanel {
class BresenhamPanel extends JPanel {
final int w, h, centerX, centerY;
final int centerX, centerY;


public BresenhamPanel() {
public BresenhamPanel() {
w = 600;
int w = 600;
h = 500;
int h = 500;
centerX = w / 2;
centerX = w / 2;
centerY = h / 2;
centerY = h / 2;