graphics

Changing colors slowly, Java Graphics

99封情书 提交于 2019-12-19 22:06:08
问题 I have a gradient background and I want, slowly, for it to change colors, basically for it to go through different colors. The color has to blend through all the colors, I do not want it to flick through colors, is this possible? Please enlighten me with a solution, thanks. 回答1: Also consider java.awt.image.MemoryImageSource and a javax.swing.Timer , illustrated here and below. 回答2: Really too hard to say anything (whatever clever) to my defense, (try & enjoy) import java.awt.*; import java

How to make drawLine smoother?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 20:28:47
问题 I use the following code to draw line: Graphics g = this.CreateGraphics(); Pen p = new Pen(Color.Black,3); g.DrawLine(p,...); // ... Why the straight line is zigzag kind of, not straight and smooth at all. How could I make it straight and smoother? 回答1: You need to enable anti-aliasing. Set Graphics.SmoothingMode to AntiAlias as described here: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.smoothingmode.aspx 回答2: Override the OnPaint() method of your form or implement the

pdf of figure in R has unsightly white lines in it

元气小坏坏 提交于 2019-12-19 18:56:50
问题 I'm trying to make colorbars, as well as raster maps, in R, and the output figures give unsightly lines in them when exported to pdf. Here is code to generate a colorbar. It looks fine when you run it in R: color.bar <- function(lut, min, max=-min, nticks=11, ticks=seq(min, max, len=nticks), title='') { scale = (length(lut)-1)/(max-min) plot(c(0,10), c(min,max), type='n', bty='n', xaxt='n', xlab='', yaxt='n', ylab='', main=title) axis(4, ticks, las=1) for (i in 1:(length(lut)-1)) { y = (i-1)

pdf of figure in R has unsightly white lines in it

纵然是瞬间 提交于 2019-12-19 18:56:23
问题 I'm trying to make colorbars, as well as raster maps, in R, and the output figures give unsightly lines in them when exported to pdf. Here is code to generate a colorbar. It looks fine when you run it in R: color.bar <- function(lut, min, max=-min, nticks=11, ticks=seq(min, max, len=nticks), title='') { scale = (length(lut)-1)/(max-min) plot(c(0,10), c(min,max), type='n', bty='n', xaxt='n', xlab='', yaxt='n', ylab='', main=title) axis(4, ticks, las=1) for (i in 1:(length(lut)-1)) { y = (i-1)

Display graphics in plots window pane rather than opening new window in RStudio

无人久伴 提交于 2019-12-19 12:37:34
问题 I googled this to no avail. I must have unknowingly changed some setting because now when I print a plot or histogram rather than displaying the plot in the plots window, a new window opens with the plot. The title of the new window reads "R Graphics: Device 2 (ACTIVE)". 回答1: It is a problem that appeared with R 3.3.0 for some RStudio versions. You can check your version with version in RStudio. It should work with a RSudio 0.99.902. For more details, check here. 回答2: Some code you ran

nearest Manhattan distance between a point and line

谁说胖子不能爱 提交于 2019-12-19 11:57:09
问题 I want to find the point on a line segment drawn in an image which is at smallest Manhattan distance from a given point. Obvious method is to get the pixels on the line segment and for each pixel calculate the distance to get the minimum. But can we do better than this ? 回答1: This is a search problem. You need to start from your point and apply a breadth first search, grow until you hit a line pixel. The children states for any pixel should be right - up - left - down neighbors. The manhattan

What code would I use to get the hex value of a color when an alpha at about half transparency is applied?

一个人想着一个人 提交于 2019-12-19 11:43:14
问题 If I have a visual element (could be text or div with color fill, doesn't matter) and the color is set to black, 0x000000 , and it's alpha is set to .4 or .5 and the background is solid white , 0xFFFFFF , the result would be a gray color. We can test this in Photoshop. What I would like to know is what code would I use to get to that result? I'm looking for something such as an equation: newColor = foregroundColor * alpha * backgroundColor Or something like in JavaScript, ActionScript or

How to calculate the normals of a box?

主宰稳场 提交于 2019-12-19 10:55:08
问题 I am trying to create an algorithm that calculate the normals of a model/ mesh. People have been telling me to use the cross products between the two vectors which at first seem like a good idea until I discovered that it might not always work. For instance just imagine a box with its front face sitting at the origin and its back face down the Z axis. Here is an image: I do apologize for bad hand writing but that shouldn't be of any significance. As you can see,I cross v and u to get the

How to calculate the normals of a box?

房东的猫 提交于 2019-12-19 10:55:00
问题 I am trying to create an algorithm that calculate the normals of a model/ mesh. People have been telling me to use the cross products between the two vectors which at first seem like a good idea until I discovered that it might not always work. For instance just imagine a box with its front face sitting at the origin and its back face down the Z axis. Here is an image: I do apologize for bad hand writing but that shouldn't be of any significance. As you can see,I cross v and u to get the

Bitmap color change while compressing to png

僤鯓⒐⒋嵵緔 提交于 2019-12-19 10:26:06
问题 I'm currently working on a steganogrpahy android app as a class project. I've created an object that will encode an image with in another image and return an encoded bitmap. This code is run in a seprate thread. new Thread(new Runnable() { public void run() { Bitmap encoded_image = null; Encryptor encryptor = new Encryptor(); encoded_image = encryptor.encode_image_in_image( image_location,message_image_location); } }).start(); After encoding the bitmap I was passing the bitmap to a file