Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [graphics2d]

Graphics2D is the part of the Java 2D API related to two-dimensional graphics, text, and imaging capabilities. Unlike the older Graphics class, Graphics2D supports coordinate transforms. It also gives better control over geometry, colors and text layout.

graphics2d
0 votes
1 answer
67 views

How do I align the X and Y axis to adjust my zoomed in grid?

I'm doing this graphing project, but I came across this problem: everytime I zoom in or out my x and y axis are out of place. Any idea of how to fix this issue? Here my code: import javafx....
alex huang's user avatar
0 votes
1 answer
62 views

Draw Unicodes/UTF-8 characters such as 'ಠ' with AWT Graphics in Java

I'm trying to draw a face with such unicodes: ಠ_ಠ However, it produces rectangles instead. I tried the following: BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB); ...
LeFlo's user avatar
  • 3
0 votes
0 answers
23 views

Increase player jump height depending on how long they hold the jump button

I need some help making my final project in java, a game. Here is the code I have now for jumping: if (Keys.up) { if (player[1] + player[3] >= base[1]) { player[5] = -20; } } This ...
Preston G's user avatar
0 votes
0 answers
31 views

why x11 xserver drawline is faster than directly write buffer?

x11 code //use x11 api for (int i = (xrectw >> 1) + cc; i < CANVAS_WIDTH; i += xrectw) { for (int j = (yrectw >> 1) + cc; j < CANVAS_HEIGHT; j += yrectw) { XDrawLine(...
A Mr's user avatar
  • 11
0 votes
1 answer
63 views

Draw a traceable text on graphics 2D

I want to teach my kids to write numbers, thus I thought of drawing traceable letters to Graphics2D I have tried the following approach float[] textDash = {15.0f}; g2d.setFont(g2d.getFont()....
Quillion's user avatar
  • 6,416
2 votes
0 answers
37 views

How to Create a Dynamic Cropping Tool with React Konva That Greys Out the Non-Cropped Area

I'm working on an image editing application using React Konva and have encountered a challenge in implementing a dynamic cropping tool. My goal is to allow users to select a crop area on an image, ...
AlePouroullis's user avatar
1 vote
1 answer
21 views

Creation of new instances of an image slows down animation and creates flickering

I'm relatively new to programming in Java. I'm trying to create objects (apples) falling in different locations on the x-axis. However every time a new one is added to the ArrayList the image slows ...
vasilis tomaras's user avatar
0 votes
0 answers
17 views

Poor line quality withJS Graphics 2D Drawing [duplicate]

I am dismayed at the poor quality of lines I draw in Graphics2D. When I draw a line with lineWidth=1 and strokeStyle="black" I would expect the line to look the same as the border of my ...
Chris B's user avatar
0 votes
1 answer
85 views

I have a small issue with drawingin Javascript Graphics 2D

Just for fun and learning, I am trying to create a web based forms editor in the manner of Visual Studio. First requirement is the ability to draw a rectangle so that the outline follows the mouse ...
Chris B's user avatar
2 votes
2 answers
61 views

(Game Design) Antialiasing in Java Graphics2d

I want to antialiase an image with shape (plane) I draw in it. I draw the plane image in Adobe AI and put them in my resource folder. The image looks like below. When I use this line of code g2....
William Li's user avatar
1 vote
1 answer
32 views

Unexpected results from Area.intersect()

I am attempting to get the intersection of two polygons via Area.intersect(), but in some cases I am getting a strange result. My code: import java.awt.Color; import java.awt.Graphics; import java.awt....
Joe's user avatar
  • 6,807
0 votes
1 answer
46 views

GeneralPath won't draw using calculated coordinate

I'm stumped. I'm trying to draw a line in a Graphics 2D environment based upon a calculated value, and GeneralPath won't do it. Basically, I want to draw a straight line based on the formula y=sx+b ...
Z81's user avatar
  • 3
0 votes
1 answer
85 views

Java Swing Graphics are drawned inconsistently when system scale is 125% in a scrollpane

at 100% screen scaling the drawn shape is always "pixel perfect". at 125% screen scaling the same shape in this case it's sometimes drawn as if it has an extra row of pixels on the top (1) ...
Fraŋkini's user avatar
  • 118
1 vote
1 answer
23 views

Unwanted cursor with Java2D drawing directly to framebuffer

The environment is Java 11 on a Raspberry Pi 3B+ with a 3.5" touchscreen. The program writes directly to the framebuffer with the aid of Thomas Welsch's JavaFrameBuffer JNI support. Things work ...
sodastream's user avatar
0 votes
1 answer
161 views

Why are there these weird visual artifacts when scrolling my BufferedImage? And how do I prevent them from happening?

I am creating an application that involves drawing a BufferedImage to a JComponent using Graphics2D in a paintComponent(Graphics) method. I added the ability to zoom in and out of the image. The ...
davidalayachew's user avatar

15 30 50 per page
1
2 3 4 5
112