How to make a transparent circle

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 523 Views - Last Post: 05 November 2017 - 02:27 AM Rate Topic: -----

#1 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

How to make a transparent circle

Posted 04 November 2017 - 10:41 AM

I want to make a 2D platformer and I want to make it look like this

Posted Image

If you want more info tell me
Is This A Good Question/Topic? 0
  • +

Replies To: How to make a transparent circle

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,857
  • Joined: 12-June 08

Re: How to make a transparent circle

Posted 04 November 2017 - 10:42 AM

What have you tried?
Are you using any frameworks or game engines?
Was This Post Helpful? 0
  • +
  • -

#3 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

Re: How to make a transparent circle

Posted 04 November 2017 - 10:44 AM

I havent really tried anything because it kind of confuses me with the code. I'm only using java for this.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,857
  • Joined: 12-June 08

Re: How to make a transparent circle

Posted 04 November 2017 - 10:46 AM

Perhaps start with the java geometric primitives.

https://docs.oracle....primitives.html
Was This Post Helpful? 0
  • +
  • -

#5 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

Re: How to make a transparent circle

Posted 04 November 2017 - 10:49 AM

I just need to know how to make a color transparent
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3444
  • View blog
  • Posts: 15,606
  • Joined: 20-September 08

Re: How to make a transparent circle

Posted 04 November 2017 - 10:53 AM

What's the difference between "won't be able to see this" and "transparent"?
Was This Post Helpful? 0
  • +
  • -

#7 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

Re: How to make a transparent circle

Posted 04 November 2017 - 11:11 AM

Hold on I did this:

		g2d.setColor(Color.black);
		g2d.fillRect(0, 0, Game.WIDTH, Game.HEIGHT);
		
		Color c=new Color(1f,1f,1f,0.3f );
		g2d.setColor(c);
		Ellipse2D.Double circle = new Ellipse2D.Double(x, y, 500, 500);
		g2d.fill(circle);


but I want it to be transparent behind the black and also can I make the edges fade
Was This Post Helpful? 0
  • +
  • -

#8 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3444
  • View blog
  • Posts: 15,606
  • Joined: 20-September 08

Re: How to make a transparent circle

Posted 04 November 2017 - 11:28 AM

I don't know if that was meant to be an answer to my question, but if it was, it didn't serve as one
Was This Post Helpful? 0
  • +
  • -

#9 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

Re: How to make a transparent circle

Posted 04 November 2017 - 12:15 PM

Its not, I made another question. And I mean transparent, so I can see anything behind the background
Was This Post Helpful? 0
  • +
  • -

#10 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3444
  • View blog
  • Posts: 15,606
  • Joined: 20-September 08

Re: How to make a transparent circle

Posted 04 November 2017 - 12:32 PM

Please make another diagram and label it accordingly in that case
Was This Post Helpful? 0
  • +
  • -

#11 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

Re: How to make a transparent circle

Posted 04 November 2017 - 12:44 PM

For the fade edges thing I want it to look like this https://gyazo.com/4e...655dec6e5c8e456

Also, for the transparent thing, it looks like this right now https://gyazo.com/85...c4414b52da31a83, because it goes transparent to the black bg. but I want it to be completely white (thru the black). So it would look like this: https://imgur.com/a/CGgxw
Was This Post Helpful? 0
  • +
  • -

#12 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1376
  • View blog
  • Posts: 4,312
  • Joined: 20-March 10

Re: How to make a transparent circle

Posted 04 November 2017 - 03:30 PM

I strongly recommend that you stop trying to use java graphics2d as your base for your platformer,

and use something like this instead,

https://libgdx.badlogicgames.com/


It will be a lot simpler and produce far better results as well...
Was This Post Helpful? 0
  • +
  • -

#13 Radishx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 14-October 17

Re: How to make a transparent circle

Posted 04 November 2017 - 03:42 PM

So there's no way of doing this? Thanks for the recommendation snoopy11, but I don't like using things like that.
Was This Post Helpful? 0
  • +
  • -

#14 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1571
  • View blog
  • Posts: 3,529
  • Joined: 05-April 11

Re: How to make a transparent circle

Posted 04 November 2017 - 04:44 PM

The trick is to first draw your black background, then draw the visible user content on top with an applied clip.
Clipping the content will make sure the user can't see everything :)
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;

import javax.swing.JPanel;


public class TestClip extends JPanel {

	public TestClip() {
		
	}
	
	@Override
	public void paintComponent(Graphics g) {
		int width = this.getWidth();
		int height = this.getHeight();
		int clipDiameter = 100;
		
		g.setColor(Color.BLACK);
		g.fillRect(0, 0, width, height);
		
		g.setColor(Color.GREEN);
		Shape ellipseClip = new Ellipse2D.Double(this.getWidth() / 2 - clipDiameter / 2, this.getHeight() / 2 - clipDiameter / 2, clipDiameter, clipDiameter);
		g.setClip(ellipseClip);
		g.fillRect(0, 0, width, height);
	}
}



Was This Post Helpful? 0
  • +
  • -

#15 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 1376
  • View blog
  • Posts: 4,312
  • Joined: 20-March 10

Re: How to make a transparent circle

Posted 04 November 2017 - 05:29 PM

Why though,

everything in Java is a library hence its cross platform nature,

Its not as if you are doing it for purity reasons as if you were, why use Java at all ??
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2