1,669 questions
2
votes
0
answers
102
views
Why does changing the FPS limit affect Graphics2D rendering performance?
I'm working with an AWT Canvas with a triple buffered BufferStrategy. The application runs a loop that renders the screen with a set maximum FPS. Specifically I'm drawing multiple characters on screen ...
1
vote
0
answers
48
views
Textures for Animation class cause errors
I am creating a platformer game and currently working on the map area (where the player selects a level). While this code does work in eclipse, it does not work when exported to a .jar file. Yes, ...
1
vote
1
answer
144
views
Java Graphics fillArc() is not precise enough
(Specifically, I'm using Graphics2D, but it inherits the fillArc() method from Graphics, so I listed the question under that class.)
The fillArc method accepts its parameters in the following order:
...
2
votes
0
answers
606
views
Fontconfig head is null exception when running AWS Lambda
I am working on creating a Lambda function that uses Spring Boot. When the API is invoked, the application makes some API calls and creates an image containing some text, generated using Java ...
0
votes
2
answers
97
views
I'm trying to draw a 2d tile map from a .txt file in java but it is only using one of the tiles accross the map and not using whats in the .txt file
I'm following a java 2d game tutorial from ryisnow on youtube. https://www.youtube.com/watch?v=ugzxCcpoSdE
I was able to display each tile on its own but I don't know why the .txt isnt working
here is ...
1
vote
1
answer
82
views
Java Graphics2D fillRect creating wrongly sized squares with a pattern
I am having an issue with a custom drawn image rendered on the JPanel with Graphics2D. If I try to draw a 1x1 pixel for every x/y the width and length of the panel with fillRect it will create a bunch ...
0
votes
1
answer
96
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....
0
votes
1
answer
269
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);
...
0
votes
0
answers
53
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 ...
0
votes
0
answers
62
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(...
0
votes
1
answer
100
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()....
2
votes
0
answers
316
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, ...
1
vote
1
answer
53
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 ...
0
votes
0
answers
20
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 ...
0
votes
1
answer
110
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 ...
2
votes
2
answers
88
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....
1
vote
1
answer
51
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....
0
votes
1
answer
85
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 ...
0
votes
1
answer
173
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) ...
1
vote
1
answer
42
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 ...
0
votes
1
answer
459
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 ...
0
votes
1
answer
125
views
Changing color when rendering SVG in PDFBox
Does anybody know how to change color when rendering SVG into PDF with pdfbox ?
I am using following code:
File svgFile = new File("roots.svg");
SVGUniverse svgUniverse = new SVGUniverse();
...
-1
votes
1
answer
550
views
java Graphics2D set stroke width dynamically
I have this code for Java Paint App.
I have added a slider that changes from 1 to 20 with a default size of 1.This slider is for changing the strokeSize dynamically,so i have created a variable ...
0
votes
1
answer
67
views
Updating graphics in a jpanel
I am struggling with refreshing the graphics in a jpanel.
I tried to make the JPanel extending class "ShadeSelectPane" update it's Graphics object everytime I use a JColorChooser to choose a ...
1
vote
0
answers
177
views
Zoom to Mouse Pointer using AffineTransform and JScrollPane
my goal is to implement an image viewer, where one can zoom to the mouse position and the JScrollPane correctly response to this zoom gesture. Also the possibility to roate the image would be nice.
I'...
2
votes
1
answer
143
views
Changing the GDI Pen won't work in my VB6 draw lines code
I am trying to use the createPen/SelectObject GDI functions to change the DC pen in a VB6 simple program.
The program is a vb6 form with Picture1 pictureBox control. It waits for the user to click ...
0
votes
1
answer
81
views
Incorrect Position and Angle of Arrowhead with AffineTransform
I have written a test program using AffineTransform to draw an arrowhead. The program takes the center of the window as the starting point of the arrowhead and the mouse position as the ending point. ...
0
votes
1
answer
57
views
Why do these chars get cut of on the bottom?
I'm building a chess board, I'm going to layer two JPanels on top of each other , the bottom one "Sideline" should display the grid code, while the top one is gong to contain the actual game ...
-3
votes
1
answer
291
views
2d cartesian plane transformation, mapping from one plane to other [closed]
If you have 4 points (xi,yi); 1<=i<=4
And you want to transform them like projective transformation to new points (Xi,Yi), how do you do it?
It can be done with matrixes... Refer here for ...
1
vote
1
answer
917
views
How to use graphics 2d in kotlin with paint()
I want to start making a 2d video game, and I found a tutorial in java. However I wanted to use kotlin because I heard it is better, I am new to java and kotlin programming and I needed to put this
...
0
votes
0
answers
49
views
My JFrame project won't paint some PNGs and will paint others even though everything is in the same directory
I have a minesweeper project that uses pngs to paint the icons for my cells. For some reason, my paint/draw methods will fill in all of the cells except mines. Everything is in the same directory. In ...
-1
votes
1
answer
427
views
Recursive Rendering in SwiftUI
My app draws dynamic complex graphics into SwiftUI Views. I understand that SwiftUI redraws Views when an observed variable changes, and that re-drawing a View deletes the existing View.
What I would ...
0
votes
1
answer
199
views
How to translate a bounding box for selection purposes with a bufferedimage rotation
I am trying to keep a bounding box local to a buffered image after it is being rotated.
Good day everyone. I am having an issue with a program I am currently working on. I draw an image to a buffered ...
2
votes
1
answer
121
views
I'm trying to draw a SRTM3-Tile with Multithreading in Java - what i'm doing wrong?
I'm trying to paint a Srtm3-Tile with the Help of Multithreading. If i use only a single Thread every works fine, but when i use Multithreading the graphic ends up in a mess. Currently i use 12 Cores -...
3
votes
0
answers
119
views
Create PNG without Text Anti-Aliasing in Java 11 on Mac OS X
When running the code below with Java 11 on Mac OS X the results differ from running it on Linux: The left side shows the output on Linux (no text anti-aliasing), the right side shows the output on ...
-2
votes
1
answer
465
views
Calculating what a spinning wheel lands on
when I spin the wheel I am unable to output the correct number that I have landed on (I always seem to get it 1 or more off depending on what i set the spinSpeed variable to). I have watched a video ...
0
votes
0
answers
21
views
Value not displayed in circle section
I want to draw a circle, then divide it into 24 equal sections, with different colors. Then add the corresponding number to each section (1 to 24)
I'm facing an issue having all the numbers displayed, ...
1
vote
0
answers
86
views
Java Print API renders on paper skewed graphics
There are 3 elements painted on imageable area in the same way. But Java Print Service draws them differently depends on whether some conditions are repected.
2 conditions are respected when paint bug ...
-1
votes
1
answer
121
views
Java Tile Flickering
Whenever I move the camera in a java game I'm working on, the edges of the tiles begin to flicker, and gaps appear between the seams, shown in the picture provided.
image flickers
I was following a ...
2
votes
0
answers
398
views
How do I stop a transparent GIF from rendering previous frames behind it?
I am using a GIF with a transparent background as a sprite for a game I am making as it is easier than manually animating each frame of the idle animation, especially since that is the only animation ...
1
vote
0
answers
87
views
Jython, wrong number of expected arguments
I'm writing a graphics app in Jython 2.7, and am doing something fundamentally wrong. I've stripped out most of the code for this question, and with the following code I get "TypeError: setColor()...
0
votes
0
answers
757
views
Graphics2D cannot be resolved to a type
I'm creating a game while following a tutorial and I came across an error. It shows Graphics2D cannot be resolved to a type. I'm new to java and I'm using Eclipse IDE (JavaSE-12). I imported the ...
0
votes
0
answers
78
views
How to connect random points inside a non-convex polygon, without intersecting with the polygon boundaries, in java
I am using code from How to get a random point on the interior of an irregular polygon? slightly modified in order to draw a random path2D by connecting random points together one after the other ...
-2
votes
1
answer
507
views
Add rotated watermark text with background to image in Java
I am using Java 8 (Spring Boot), and I want to add text (as watermark) to an image like this:
As you see, the text HELLO WORLD! is rotated 90 degrees, and it has black background color (the grey ...
2
votes
0
answers
431
views
Can I use Apache Batik to paint an SVG to an AWT Graphics2D context?
I have successfully read an SVG file into an org.w3c.dom.Document to see its structure.
Now I'd like to render it to the screen using Java's AWT's Graphics2D.
Note:
I don't want to use Swing (e.g., ...
0
votes
0
answers
75
views
Draw line shape with length and send length value to JTable
I created three classes: one is Gui class it includes JTable and JButton.
public class Gui {
public void Gui() {
JFrame frame = new JFrame();
String data[][] = {};
String ...
1
vote
1
answer
359
views
Java Graphics2D drawRect throw "sg2d.loops" is null
java.lang.NullPointerException: Cannot read field "fillParallelogramLoop" because "sg2d.loops" is null
at java.desktop/sun.java2d.pipe.LoopPipe.fillParallelogram(LoopPipe....
0
votes
1
answer
164
views
How do I create a gradient of 3 colors in Java
I am developing a navigation system in Java. The map should be drawn in the middle, with indicators on the left and right.
How do I make the map slowly fade out on both sides?
As shown above, the ...
-1
votes
1
answer
33
views
clear Jpanel before next time drawing
I've created an analogclock were u can type a digital time and the program draws a clock that shows the time and updates it self secondly. But at every update the old lines still remain. the variables ...
-1
votes
1
answer
78
views
Java Swing: Reusing a parent JPanel graphics2D reference in child JPanels
I am relatively new to Java Swing and I have a use case where I have a single JPanel that needs to be divided into 2 equal sections horizontally.
Each section needs to display a graph with added ...