2D Circle Texture Rotation?

Jan 11, 2015

So I have this randomly generated set of tiles that is wrapped in a circle and I'm not really sure how to scroll it around the circle. Basically it's a side-view planet that is in 2D and needs to be wrapped and moving at a controllable rate to give the illusion of planet rotation. What to do to the x and y to make it scroll around. I want every tile except the water tiles to move from left to right and then wrap around the circle. Here's what a planet looks like: [URL] ....

Java Code:

for (int x = 0; x < planet1.length; x++)
{
for (int y = 0; y < planet1[0].length; y++)
{
if (planet1[x][y] == 1 || planet1[x][y] == 2)
{
g.drawImage(water, x * 32, y * 32);

[Code] ....

View Replies


ADVERTISEMENT

How To Make Custom Texture System For A Block In Minecraft

Apr 20, 2014

I am trying to make a custom texture system for a block in Minecraft, I am not too advanced with Java and am not sure how to make this work the way I want it to.

/** The list of the types of step blocks. */
public static final String[] blockStepTypes = new String[] {"stone", "sand", "wood", "cobble", "brick", "smoothStoneBrick", "netherBrick", "quartz"};
  private Icon missing;
private Icon icon1;
 
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/

[Code] .....

Alright, so basically I figured I could just tell the code to see if the block is made out of Stone, then to set the texture to Stone, or if it's made out of Sand, then set it to Sand.

What I usually get is Eclipse telling me to "insert '!= null' check", "insert '!= null' check", and then just error out saying "Opperator != is undefined for the argument type(s) boolean null"

Is there any way I could make this work for me? Maybe some other way to make it do what I am trying to do?

View Replies View Related

Image Rotation And Alignment

Mar 22, 2014

My problem in order to align and and rotation for image?

View Replies View Related

Graphics Rotation In Swing

Feb 3, 2014

How to rotate a shape in Swing? The only thing I found was something involving this, but I have not seen something like this before:

Java Code : Graphics2D g2d = (Graphics2D)g; mh_sh_highlight_all('java');

I see this is an object reference, but what is on the right side? Does not seem like a method, as it would not equal a method nor would the parentheses be on the left. Why are parentheses there? Disregarding the above code, I would like to know how to rotate without Graphics 2d

Also, with G2D you it will not allow for setting x coords

View Replies View Related

Swing/AWT/SWT :: AffineTransform - Rotation Is Being Ignored When Set Transform

May 31, 2014

I'm experimenting with AffineTransform, Basically I've created just a simple test GUI to see how the code works and all that. Anyway, there are two buttons which turn an image left and right and a third button with moves the image to the right (East). When you first run the program the image is facing down (South). Now to turn left or right I'm using an Affine Transform and the rotate method. That works fine. The issue is when I move the image to the right, it ignore whatever rotation I previously I made (from turn left and right buttons). Therefore when I click to move the image, it faces down again even if it was facing left or up or right before I moved it. It will always be facing down. How do I get it to keep the rotation and just move? Btw I'm using the setTranslate method to move the image.

Below is my code.

Images.java
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
public class Images {
static BufferedImage Icon, Rover;

[Code] ....

View Replies View Related

JavaFX 2.0 :: Panel Effect - Rotation Along Its Y Axis

Dec 14, 2014

I have a UI widget, like a table view for example, displaying real-time data. This table can be configured - so it has many properties. The way I would like to do so, is to have a small 'configure button', once clicked, would rotate the entire table along its y axis, and display another panel with checkboxes etc... So effectively, the hidden properties panel is revealed by rotation.

View Replies View Related

Swing/AWT/SWT :: 2D Spaceship Game - Image Rotation And Position

Aug 29, 2014

I'm attempting to create a 2D spaceship game from scratch. My problem is that I feel like the way Im rotating images is awkward and just wrong. I believe what I'm doing in the following code is loading an image into a JPanel and rotating the image and moving the JPanel.

The code is unrefined and only partial, but it show how I am manipulating images.

import java.util.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.geom.AffineTransform;
import javax.swing.*;
import java.lang.Math.*;
import java.io.*;
import javax.imageio.*;

[Code] .....

What seems so awkward is that I have to create a new JPanel for every image, I would think there is a better way but I don't know. I have tried to get one image on top of an other with the JPanels to no avail. That said I haven't put much time into trying to get that to work. I want to know if I should continue my attempt with JPanels or to pursue a different method.

View Replies View Related

JavaFX 2.0 :: Image Overlay Rotation Interpolation Error

Jun 12, 2015

I'd like to draw an overlay on an image. The overlay is also an image with a black background and a white foreground. Now the white pixels should be drawn on the image in red. This is possible with the code I posted below. However, the problem arises when rotating the stencil (overlay). I get some interpolation errors from the rotation on the boundaries. I tried to clip them with setClip(), but this turns the background from transparent to white. How to remove those spots? Or maybe a completely other idea of achieving an overlay on the image? I'm aware of the pixelreader and iterating through the stencils pixels and draw the respective pixels as rectangles on a Canvas' graphicContext. However, this was extremely slow, compared to the code I posted below (although it doesn't work with rotations).

Here I surrounded the errors:
 
The image:
 
The stencil:
 
And here is the code:
 
import javafx.application.Application; 
import javafx.geometry.Insets;
import javafx.scene.*;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.*;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

[Code] .....

View Replies View Related

JavaFX 2.0 :: 3D Sphere To Represent Each Single Point - Rotation Lagging With Large Number Of Points

May 22, 2014

We are doing a visualisation tool for point cloud research project. We use 3d sphere to represent each single point and when we have large number of points to display (~40,000), the rotation becomes very lagging.
 
What we have tried:

set JVM flag -Djavafx.animation.fullspeed=true, this worked a bit, but not significant.set JVM flag -Djavafx.autoproxy.disable=true, this did not work.

set Cache to true and CacheHint to Cache.SPEED, this did not make much difference.create another thread to do the rotation, and sync back after calculation, this did not work neither.

View Replies View Related

How To Do Nested Circle Dynamically

Feb 8, 2015

i'm trying to do a nested circle dynamically. i don't know whats wrong with my program ...

private Ellipse2D.Float doubleElip(int x1, int y1, int x2, int y2){
int x = Math.min(x1, x2);
int y = Math.min(y1, y2);
int width = Math.abs(x1 - x2);
int height = Math.abs(y1 - y2);
for( int i=0; i < 1; i++){
Ellipse2D.Float elip = new Ellipse2D.Float(x , y,
width/i, height/i);
}
return elip;
}

View Replies View Related

Calculating Area And Circumference Of A Circle

Apr 21, 2014

Here is the code that I wrote out:

//program that calculates the circumference and area of a circle

import java.util.Scanner;
public class circle{
public static void main(String[] args){
Scanner input= new Scanner( System.in);
double r; //declares radius

[Code] .....

And here is what is displayed in the command prompt when I compile my code:

circle.java:17: error: cannot find symbol
r.input.nextdouble();//entered the radius
symbol: method nextdouble()
location: variable input of type Scanner
1 error

What am I doing wrong?

View Replies View Related

Swing/AWT/SWT :: How To Do A Nested Circle Dynamically

Mar 5, 2015

i want to draw a circle inside a circle in java. so far i'm using this piece of code

private Ellipse2D.Float drawEllipse(int x1, int y1, int x2, int y2) {
int x = Math.min(x1, x2);
int y = Math.min(y1, y2);
int width = Math.abs(x1 - x2);
int height = Math.abs(y1 - y2);
return new Ellipse2D.Float(x, y, width, height);
}

View Replies View Related

Calculating Points On A Circle Using Radius

Oct 24, 2014

I have to print points on a circle in increments of -0.1, but when I use a number larger than 1.3, the list stops at 0.1 larger than negRadius, and I don't know why. (Assume the center is (0,0))

public class PointsOnACircleV1
{
public static void main(String[] args)
{
double radius = 1;

[code]...

View Replies View Related

Counting Number Of Steps Throughout The Circle

Jan 27, 2015

The method public static int steps(int posts, int stride) calculates how many strides can be taken to get back to posts. Let's say if the method is (12, 4), it takes only three steps. Now let's say the method has parameters (12,5), so it should be (5, 10, 3, 8, 1, 6, 11, 4, 9, 2, 7, 12). My method works for such examplse as (12, 4) or (12,3) or (6,2)... but how can I figure out (12,5)?

Java Code:

public static int steps(int posts, int stride) {
int countSteps = 0;
int result = 0;
do {
result += stride;

[Code] ....

View Replies View Related

Program To Calculate Area Of Circle

Mar 11, 2015

I'm starting with my version of very basic program: calculating area of circle. And of course it doesn't get well. My question: what is wrong in this code?

public class circleAre{
double radious;
void putData(double radi){
radi = radious;

[Code] .....

View Replies View Related

Make A Circle With Java Coding

Aug 12, 2014

i want to make a circle with java coding.... i tried but i am grtting some error...

View Replies View Related

Shade Portion Of Circle Based On Area Given?

Sep 23, 2014

I am able to draw this image using filloaval() but afterwards when i am calculating some area i have to shade that in the figure in some different color

R is fixed to 100 and d lies between 0 to R

View Replies View Related

Moving Circle - Null Pointer Exception

Apr 9, 2014

I am try to move circle.Below is my code...

import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
import javax.swing.JPanel;

[Code] .....

And I have error

run:
Exception in thread "main" java.lang.NullPointerException
at swingdesing.Game.buffer(Game.java:32)
at swingdesing.Game.moveBall(Game.java:27)
at swingdesing.Game.main(Game.java:51)
BUILD SUCCESSFUL (total time: 9 seconds)

how to overcome this?

View Replies View Related

Write A Class Encapsulating Concept Of A Circle?

Mar 19, 2014

Prompt: Write a class encapsulating the concept of a circle, assuming a circle has the following attributes: a Point representing the center of the circle, and the radius of the circle, and integer.

Include a constructor, the accessors and mutators, and methods toString and equals.
Also include methods returning the perimeter ( 2 x 𝜋 x 𝑟 ) and area ( 𝜋 x 𝑟^2) of the circle.
Write a client (application) class to test all the methods in your class. I started out trying to thing how to do this and I mapped out a certain idea but do not know how to incorporate the point represent the center of the circle. I am not sure how to proceed further..

import java.awt.*;
public class Circle {
 public static void main(String[] args) {
 
final double PI = 3.14;
int x,y, radius = 4;
double area;
double perimeter;
 
[Code] ...

View Replies View Related

LightController And Circle Class - Creating A Constructor

Jan 6, 2015

I have two classes LightController & Circle. I need to use the LightController class to do the following:

Creates an instance of Circle with a diameter of 50 and a colour of OUColour.GREEN and assigns this new circle to the instance variable light.

Sets the xPos of light to 122.
Sets the yPos of light to 162.

I am struggling to write the correct line of code to set the colour to green and set diameter to 50.

Code for the two classes below.

001
import ou.*;
002
import java.util.*;
003
/**
004
* Class LightController
005
* This class uses the Circle class, and the Shapes window

[Code] ......

View Replies View Related

How To Calculate Area Of Triangle / Circle / Rectangle

Mar 3, 2015

package areatest;
import javax.swing.JOptionPane;
public class AreaTest {
 
public static double areaTriangle (double length, double width){ //How to calculate the area of a triangle
return .5f * length * width;

[Code] .....

When I try to get the area of a rectangle it gives me 9 no matter what input I give it. When I try to get the area of a triangle it gives me .5 no matter what input I give it. Same with the circle but it always gives me 12.56370...

View Replies View Related

Method Should Return A Double That Is Diameter Of Circle

Jul 9, 2014

What's that diameter? Create a new method for the circle class called diameter. Add this method to the circle class described on page 15-1. It should return a double that is the diameter of the circle. No parameters are passed to this method.

In a tester class, test the performance of your new diameter method as follows:

(Your project should have two classes, Tester and Circle.)

here is what i have so far:

public class Circle
{
public Circle (double r)
{
radius = r;
}
public double area()
{
double a = Math.PI * radius * radius;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Draw A Line (Horizontal) Inside A Circle

Mar 12, 2015

I want to draw a line inside a circle, i what to have a horizontal line. Here is what i have done so far.

import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.Dimension;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Drawing A Semicircle Using Formula For The Equation Of A Circle

Sep 19, 2014

So Ive got to make a turtle on an image draw a semicircle that starts at the top of a circle and goes down and to the left, changing colors halfway through. I've got everything down, I can draw the turtles and make them do straight lines. My problem is more math related. I need to use the equation of a circle, give it points, and figure out how to write that code in java.

We use the equation for a circle: (x - a)^2 + (y - b)^2 = r^2

amanda.setName("amanda");
amanda.setShellColor(Color.BLUE);
amanda.setBodyColor(Color.RED);
amanda.setPenColor(Color.YELLOW);
amanda.setPenWidth(3);
amanda.forward();
amanda.turn(-90);
amanda.setPenColor(Color.BLUE);
amanda.forward(???);

the question marks are where I need to draw a line on an arc, like in the picture.

View Replies View Related

Java Program To Test Circle Dimensions To Prove Pie

Apr 28, 2015

So in trying to create a circle class, and use the dimensions of that circle (radius, area, etc.) to prove it will equal pie and print (3.141592653589793). This is my code so far it and am getting an error in the last two classes. I know it has to do with Circle(Radius); in the 2nd class but whenever i call upon it, it is assigned to itself. And in the last class im not too sure how to put the B= new b(1,1).

[public class Circle {
private double radius;
public Circle() {
radius = 0;
}
public Circle(double radius) {
this.radius = radius;

[Code] .....

View Replies View Related

Method GetRadius In Class Circle Cannot Be Applied To Given Types

Sep 15, 2014

I am getting an error with my code. How to fix it.

import java.util.Scanner;
import java.util.*;
/*
* FileName: Circle.java
*/

public class Circle {
private double PI = 3.14159;
private double radius;
public Circle()
{
radius = 0.0;

[Code] ....

This is the error i am receiving:

Circle.java:78: error: method getRadius in class Circle cannot be applied to given types;
System.out.println("A circle with a radius of " + circle.getRadius() + " will have an area of " + circle.getArea() + " , a diameter of " + circle.getDiameter() + " and a circumference of " + circle.getCircumference());
^
required: double
found: no arguments
reason: actual and formal argument lists differ in length
1 error

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved