Skip to content

Tag: graphics

how to draw prespctive image in android canvas

i have searched about how to draw prespctive image in canvas like in the picture but i dont find anything thing. if its not possible using canvas, how i can make something like it? i find this:- but this cut the image. Answer This is possible by magic method of canvas drawBitmapMesh. This is example from my p…

Java awt draw elements around a circle

I’m currently writing a little game and I came over a problem. I need to draw 64 small circles at the border of a big circle. So I want something like this: I’ve already tried many things, but they didn’t worked. How can this be done in java, using the java.awt.Component#paint() method and t…

How could one draw sheet music from MusicXML in Java?

I am currently working on a sight-reading app that requires display of musical notation; I am struggling to find a way to efficiently draw this in a JFrame. I am looking at the JFugue library to help with this, and the description of the class MusicXMLParser_J states the following. Parses a MusicXML file, and…

Java paint line in existing JPanel with components

I’ve been searching for a few hours, including at other questions on stack such as. I need simplest way to draw a line in java in AWT panel but couldn’t find my answer. I have a panel gridbaglayout with multiple dynamically generated components. The class extends JFrame and thus can’t extend…

Extending the Graphics class in Java

I need to extend the Graphics class in order to @Override some methods including drawRect(int,int,int,int) and drawRoundRect(int,int,int,int,int,int). However, I have no idea how to do that. This is what I’ve got so far: I get an error on class declaration line saying: myGraphics is not abstract and doe…

Java Graphics Invert Color Composite

Basically what I want to do is make a cursor for a JComponent that’s pixels appear as the inverse of the color they are over. For example, take your mouse and hover it over the letters in the url for this page. If you look closely, the pixels of the cursor that are over black pixels of a letter turn

Drawing rectangles at an angle

What is a method in Java that draws a rectangle given the following: The coordinates of the center of the square The angle of the rectangle from vertical, in degrees Answer To draw a rectangle in the way you suggest you need to use the class AffineTransform. The class can be used to transform a shape in all m…