graphics

How can I set RenderingHints globally?

旧巷老猫 提交于 2019-12-21 13:09:42
问题 For a Java application, can I set the RenderingHints on a global basis? Currently, I've defined these in the paintComponent method as shown below. I would prefer, however, to set them once when the application starts and have them persist throughout the session. @Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint

Drawing a graph in the corner of another

℡╲_俬逩灬. 提交于 2019-12-21 12:57:49
问题 How should I present a small plot in the corner of another plot in R? 回答1: I've done this using something like this: # Making some fake data plot1 <- data.frame(x=sample(x=1:10,10,replace=FALSE), y=sample(x=1:10,10,replace=FALSE)) plot2 <- data.frame(x=sample(x=1:10,10,replace=FALSE), y=sample(x=1:10,10,replace=FALSE)) plot3 <- data.frame(x=sample(x=1:10,10,replace=FALSE), y=sample(x=1:10,10,replace=FALSE)) layout(matrix(c(2,1,1,3,1,1),2,3,byrow=TRUE)) plot(plot1$x,plot1$y) plot(plot2$x,plot2

FBO Blitting is not working

半世苍凉 提交于 2019-12-21 12:57:20
问题 I'm trying to render a multisampled scene to texture, here is the code I'm using. I'm getting a black screen. I check the fbo completeness at the end of init, and they report that both fbo's are complete. void init_rendered_FBO() { glGenFramebuffers(1,&fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glGenTextures(1,&fbo_tex); glBindTexture(GL_TEXTURE_2D, fbo_tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO

How to approach Java 2D performance variations between different computers?

核能气质少年 提交于 2019-12-21 12:42:36
问题 I've been designing a card game in Java on Windows. It runs really well on my laptop and a few others, but on a lot of other systems (even a few newer ones both Mac and Windows) the animation is incredibly slow. I've found User Interface Toolkits for Java to be the best resource so far, but haven't been able to make a significant improvement. I'm using the AWT/Swing libraries. Question: Looking at my game, (<1.5Mb), how could it be that on some computers (of similar spec) the performance

Drawing lines with Bresenham's Line Algorithm

你说的曾经没有我的故事 提交于 2019-12-21 09:21:51
问题 My computer graphics homework is to implement OpenGL algorithms using only the ability to draw points. So obviously I need to get drawLine() to work before I can draw anything else. drawLine() has to be done using integers only. No floating point. This is what I was taught. Basically, lines can be broken up into 4 different categories, positive steep, positive shallow, negative steep and negative shallow. This is the picture I am supposed to draw: and this is the picture my program is drawing

..level.. in ggplot2 contour plot

☆樱花仙子☆ 提交于 2019-12-21 07:54:56
问题 I find this variable a little confusing, for example, from the docs: require(ggplot2) require(reshape2) volcano3d <- melt(volcano) names(volcano3d) <- c("x", "y", "z") v <- ggplot(volcano3d, aes(x, y, z = z)) v1 = v + stat_contour(aes(colour=..level..,size=..level..)) Why can't I use this: v2 = v + stat_contour(aes(colour=as.factor(z),size=as.factor(z))) 回答1: From Hadley Wickham's A Layered Grammar of Graphics, page 21, the .. .. is used because the aesthetic (in this case, the levels of the

Graphics2D: Drawing black on white?

拟墨画扇 提交于 2019-12-21 07:07:04
问题 I'm sure this is a very stupid question but I can't find the answer, I'm not experienced with the Java2D API. I'm trying to create an image and write it to GIF or PNG, and I want it to use a black pen on a white background. If I don't set any colors, I get white on black. If I use setPaint() (intended for subsequent draw operations) I get the whole canvas repainted with that color. The following sample renders the whole thing black. The sample is in Scala but you get the idea. Feel free to

Android - Zoomed View translation limiting

故事扮演 提交于 2019-12-21 06:42:11
问题 I have a simple Custom View and Scale Gesture detector implemented for the Pinch (zoom) gesture, just like this (found it on StackOverflow too): import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.view.View; public class MyImageView extends View { private static final int INVALID

(Delphi THintWindow) How to draw a transparent PNG?

爷,独闯天下 提交于 2019-12-21 06:39:33
问题 I have this delphi 2010 code: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Math, ExtCtrls, pngimage; type TMyHintWindow = class(THintWindow) private FBitmap : TBitmap; ThePNG : TPngImage; FRegion : THandle; procedure FreeRegion; protected procedure CreateParams(var Params : TCreateParams); override; procedure Paint; override; procedure Erase(var Message : TMessage); message WM_ERASEBKGND; public constructor Create

How to save objects previously drawn to the Canvas on a redraw?

久未见 提交于 2019-12-21 06:06:27
问题 Every time a SurfaceView is redrawn, things that were previously drawn are erased. How do I save their state so that my loop will add new objects to the screen without erasing the old ones? 回答1: Draw with a Bitmap : Bitmap mDrawBitmap; Canvas mBitmapCanvas; Paint mDrawPaint = new Paint(); @Override public void onDraw(Canvas canvas) { if (mDrawBitmap == null) { mDrawBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888); mBitmapCanvas = new Canvas(mDrawBitmap); } //