graphics

Refraction in Raytracing?

匆匆过客 提交于 2020-01-11 17:41:48
问题 I've been working on my raytracer again. I added reflection and multithreading support. Currently I am working on adding refractions, but its only half working. As you can see, there is a center sphere(without specular highlight), a reflecting sphere(to the right) and a refracting sphere(left). I'm pretty happy about reflections, it does look very good. For refractions its kinda working...the light is refracted and all shadows of the spheres are visible in the sphere(refraction index 1.4),

Refraction in Raytracing?

扶醉桌前 提交于 2020-01-11 17:41:42
问题 I've been working on my raytracer again. I added reflection and multithreading support. Currently I am working on adding refractions, but its only half working. As you can see, there is a center sphere(without specular highlight), a reflecting sphere(to the right) and a refracting sphere(left). I'm pretty happy about reflections, it does look very good. For refractions its kinda working...the light is refracted and all shadows of the spheres are visible in the sphere(refraction index 1.4),

How to initialize Graphics? because it says it was not initialized [closed]

血红的双手。 提交于 2020-01-11 14:35:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have this part of my code but it will not initialize and I do not know how to do it. It keeps giving me an error such as Exception in thread "main" java.lang.NullPointerException at memor.main(memor.java:131) import java.awt.*; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.GridLayout;

Point to grow and shrink by using gl_PointSize

喜欢而已 提交于 2020-01-11 12:34:28
问题 I'm Trying to grow and shrink an point by using this function glPointSize() float i; for (i = 0.0; i < 400.0; i ++) { glPointSize(i); } while (i > 0.0) { glPointSize(i); i--; } it just point, Couldn't know how to make it move? 回答1: Implementations have a limitation on the size of points. The GL_POINT_SIZE_RANGE can be used to fetch this limit, but it will generally be rather less than 400. A larger point size will be clamped to this range. 来源: https://stackoverflow.com/questions/57936064

FillPolygon with holes

眉间皱痕 提交于 2020-01-11 12:32:21
问题 I want to create a "fill" that fills the inside of a polygon, created using a point list, but be able to remove its holes. My old code: Private Sub DrawSomething(ByVal points as List(of Point), _ ByVal myBrush As System.Drawing.Brush, _ ByVal myGraphics As System.Drawing.Graphics) myGraphics.FillPolygon(myBrush, points) End Sub It simply fills a polygon created by the contour of the points in the list. How can I fill the polygon, but exclude the holes in it (which I know are inside, I have

How to Draw a given Character in exact height?

ぐ巨炮叔叔 提交于 2020-01-11 11:51:49
问题 I am drawing the text using Graphics.DrawString() method, But the text height drawn is not same as which i gave. For Eg: Font F=new Font("Arial", 1f,GraphicUnit.Inch); g.DrawString("M", F,Brushes.red,new Point(0,0)); By using the above code, i'm drawing the text with height 1 inch, but the text drawn is not exactly in 1 inch. I need to Draw the text in Exact height which i'm giving. Thanks in advance.. 回答1: The simplest solution will be to use a GraphicsPath . Here are the steps necessary:

How to Draw a given Character in exact height?

拟墨画扇 提交于 2020-01-11 11:50:05
问题 I am drawing the text using Graphics.DrawString() method, But the text height drawn is not same as which i gave. For Eg: Font F=new Font("Arial", 1f,GraphicUnit.Inch); g.DrawString("M", F,Brushes.red,new Point(0,0)); By using the above code, i'm drawing the text with height 1 inch, but the text drawn is not exactly in 1 inch. I need to Draw the text in Exact height which i'm giving. Thanks in advance.. 回答1: The simplest solution will be to use a GraphicsPath . Here are the steps necessary:

use super.paintComponent(g) or getGraphics() in java

余生长醉 提交于 2020-01-11 06:44:13
问题 i' m little bit confused about few things: Example code,that shows my problem,this isn't compilable // image private BufferedImage image; private Graphics2D graphic; private changeImage; . . . //thread loop while (running) { . . . render(); Graphics showGraphic = getGraphics(); showGraphic.drawImage(image, 0, 0, null); showGraphic.dispose(); } public void render(){ if(changeImage == 1) graphic.drawImage(ImageLoader.TREE, 0, 0, null); else if(changeImage == 2){ graphic.drawImage(ImageLoader

Line clipping to arbitary 2D polygon

和自甴很熟 提交于 2020-01-11 05:04:55
问题 If I get a line segment which was long enough to cross a given polygon, which could be concave or convex polygon. How did I find the all the intersected light segments which was contained in the polygon? If the target region is not polygon, but a implicit curve function or spline curve, how to do it? Thanks! 回答1: There really isn't a simple solution to your problem, especially with curves (beziers and splines). On top of the complexities of polygon clipping, there's the considerable challenge

drawing text within a JPanel

馋奶兔 提交于 2020-01-11 02:48:29
问题 I'm looking for the most basic description of how to draw text within a JPanel. I know there are a billion tutorials out there but none of them are clicking with me and I have some specific questions which may help others who are confused. As a setup (a testing app) I have a single class which has a JLabel, a JTextField, a JButton, and a JPanel. The application reads in ints from an external file and should display their average in the panel when the JButton is pressed. I have all the