All Downloads are FREE. Search and download functionalities are using the official Maven repository.

examples.linear.circular.application.CircularApplication Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
package examples.linear.circular.application;

import java.awt.Color;

import br.com.etyllica.commons.context.Application;
import br.com.etyllica.commons.event.PointerEvent;
import br.com.etyllica.core.graphics.Graphics;
import br.com.etyllica.linear.Point2D;

public class CircularApplication extends Application {

	private static final int NUM_POINTS = 20;
	private static final int RADIUS = 50;
	private Point2D center;
	
	public CircularApplication(int w, int h) {
		super(w,h);
	}

	public void load() {
		center = new Point2D(100, 200);
		
		loading = 99;
	}
	
	public void draw(Graphics g) {
		g.setColor(Color.BLACK);
		
		drawPoint(g, center);
		
		for(int i = 0; i < NUM_POINTS; i++) {
			Point2D point = new Point2D(center);
			point.setOffsetX(RADIUS);
			point.rotate(center, (double)(360/NUM_POINTS)*i);
			drawPoint(g, point);
		}
	}
	
	private void drawPoint(Graphics g, Point2D point) {
		g.fillCircle(point, 5);
	}
	
	@Override
	public void updateMouse(PointerEvent event) {
		//dynamic position
		center.setLocation(event.getX(), event.getY());
	}

}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy