graphics

Algorithm or software for slicing a mesh

丶灬走出姿态 提交于 2019-12-20 09:18:49
问题 What is the right approach for slicing a 3D mesh? The mesh are all closed surfaces and the slices need to be binary images of what's inside the mesh. So for example, a mesh representing a sphere and slice images are those of filled circles. I am looking for a software library or algorithm that I can integrate into my current C++ project. 回答1: My open source game library contains an implementation of mesh slicing. It works with the Irrlicht api, but could be rewritten to use a different API

Simple algorithm for drawing filled ellipse in C/C++

北战南征 提交于 2019-12-20 09:04:04
问题 On SO, found the following simple algorithm for drawing filled circles: for(int y=-radius; y<=radius; y++) for(int x=-radius; x<=radius; x++) if(x*x+y*y <= radius*radius) setpixel(origin.x+x, origin.y+y); Is there an equally simple algorithm for drawing filled ellipses? 回答1: Simpler, with no double and no division (but be careful of integer overflow): for(int y=-height; y<=height; y++) { for(int x=-width; x<=width; x++) { if(x*x*height*height+y*y*width*width <= height*height*width*width)

RGB filters for different forms of color blindness

谁都会走 提交于 2019-12-20 08:49:32
问题 My father is color blind and given that I work in games where the visuals are important, I've always wanted to write a filter for screen shots (or even some type of shader) that emulated different forms of color blindness. I've seen plenty of references but never have been able to track down algorithms. Any algorithms would be appreciated. 回答1: My Google search came up with this one, which appears to be exactly what you're looking for. Eight different versions of color blindness are simulated

How to use an arrow marker on an SVG <line> element?

有些话、适合烂在心里 提交于 2019-12-20 08:48:22
问题 I need to create an arrow in d3.js, but all I find are examples with diagrams of nodes. What I need is to simply make an arrow that goes from point A to point B. I tried implementing part of the code in the following example: http://bl.ocks.org/1153292 This specific part: svg.append("svg:defs").selectAll("marker") .data(["suit", "licensing", "resolved"]) .enter().append("svg:marker") .attr("id", String) .attr("viewBox", "0 -5 10 10") .attr("refX", 15) .attr("refY", -1.5) .attr("markerWidth",

How to calculate the normal matrix?

不打扰是莪最后的温柔 提交于 2019-12-20 08:19:11
问题 I have some trouble with my normal matrix. vs.glsl #version 440 in vec3 vPosition; in vec3 vNormal; out vec4 eyeCordFs; out vec4 eyeNormalFs; uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { mat4 modelView = view * model; mat4 normalMatrix = view * transpose(inverse(model)); vec4 eyeNorm = normalize(normalMatrix * vec4(vNormal, 0.0)); vec4 eyeCord= modelView * vec4(vPosition, 1.0); eyeCordFs = eyeCord; eyeNormalFs = eyeNorm; gl_Position = proj * modelView * vec4(

JFrame not displaying all images in fullscreen

纵饮孤独 提交于 2019-12-20 07:15:03
问题 So, I am working on a project which requires switching between images. The images need to be in fullscreen mode. There seem to be 2 problems that I am facing. First is with the image switching. When I switch between images, some images appear ok when I switch. Others dont seem to show up on the screen at all. I just seem to be getting an empty frame. Second is that the right key seems to work everytime but just for my sanity, I have put system prints. The system outs dont seem to show up on

Leaving a trace while painting on a transparent JPanel

南笙酒味 提交于 2019-12-20 06:47:25
问题 I am relatively new graphics programmer in Java and here is a simple program I was trying. Here is the full code: broken into 3 classes. Class 1: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MyPanelB extends JPanel { int x=0; int y=0; public void paintComponent(Graphics g) { x=x+1; y=y+1; setOpaque(false); //setBackground(Color.cyan); g.setColor(Color.red); g.fillRect(x,y,x+1,y+1); } } Class 2: import javax.swing.*; import java.awt.*; import java.awt.event.*;

change the size of JTextField on KeyPress

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 06:43:46
问题 I have to extend the size of JTextField on KeyPressed event as user enter the text in textfield.please give me some idea how to achieve this? thanks in advance 回答1: Okay, jumping for it :-) Let's assume the question is How to adjust a JTextField's width to always fit its content width? Usual collaborators a LayoutManager which sizes its children at their pref size, f.i. FlowLayout JTextField reports its pref size fitted to content auto-magical resize expected Quick example: JTextField field =

Java Graphics Checkout Simulation;

耗尽温柔 提交于 2019-12-20 06:27:59
问题 I am working on a project which is a Checkout Simulation. I have the code to make it work run but i am struggling to understand and implement how to add graphics(in my case a square) once a certain condition is true. For example i have made my code so that it goes through random numbers and if 2,4,6 or 8 has been randomly generated, someone will be added to the queue and the same goes for if they are even numbers 1 or 3, someone is removed from the queue. I basically just want to know how to

Remove the black background color of a bitmap

一个人想着一个人 提交于 2019-12-20 06:26:02
问题 I need to remove the black background color of a bitmap in C# VS2013. It is just like that I draw some points on a canvas. The canvas is black and I just need to change the canvas to be transparent meanwhile keeping colorful points on it without any changes. I got the solution at: How to remove white background color from Bitmap Bitmap capcha = new Bitmap(@"C:/image.png"); capcha.MakeTransparent(Color.Black); But, the background still have a gray color like a fog covering the points on the