graphics

Easy way to display a continuously updating image in C/Linux

谁说胖子不能爱 提交于 2019-12-18 11:57:27
问题 I'm a scientist who is quite comfortable with C for numerical computation, but I need some help with displaying the results. I want to be able to display a continuously updated bitmap in a window, which is calculated from realtime data. I'd like to be able to update the image quite quickly (e.g. faster than 1 frame/second, preferably 100 fps). For example: char image_buffer[width*height*3];//rgb data initializewindow(); for (t=0;t<t_end;t++) { getdata(data);//get some realtime data docalcs

How do I use glutBitmapString() in C++ to draw text to the screen?

只愿长相守 提交于 2019-12-18 11:56:58
问题 I'm attempting to draw text to the screen using GLUT in 2d. I want to use glutBitmapString(), can someone show me a simple example of what you have to do to setup and properly use this method in C++ so I can draw an arbitrary string at an (X,Y) position? glutBitmapString(void *font, const unsigned char *string); I'm using linux, and I know I need to create a Font object, although I'm not sure exactly how and I can supply it with the string as the second arguement. However, how do I also

Using SVG for additive color mixing (additive blending)

放肆的年华 提交于 2019-12-18 11:55:33
问题 Coming from a graphic design background I know how to cheat to create an effect of additive color. The same basic solution is proposed in another post on here. The post above refers to transparent .png files but the concept is the same. The basic effect I'd like to create is like the one pictured here. I'd love to do it in SVG so that it can scale and so that when I am talking about a given topic (let's just say the topic is 'green') I can enlarge that portion of the graphic and the

How to overlay a line for an lm object on a ggplot2 scatterplot

余生长醉 提交于 2019-12-18 11:55:30
问题 I have some data, calvarbyruno.1<-structure(list(Nominal = c(1, 3, 6, 10, 30, 50, 150, 250), Run = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("1", "2", "3"), class = "factor"), PAR = c(1.25000000000000e-05, 0.000960333333333333, 0.00205833333333334, 0.00423333333333333, 0.0322333333333334, 0.614433333333334, 1.24333333333333, 1.86333333333333), PredLin = c(-0.0119152187070942, 0.00375925114245899, 0.0272709559167888, 0.0586198956158952, 0.215364594111427, 0.372109292606959, 1

Set form backcolor to custom color

被刻印的时光 ゝ 提交于 2019-12-18 11:45:05
问题 How can I set a form's backcolor to a custom color (such as light pink) using C# code? 回答1: If you want to set the form's back color to some arbitrary RGB value, you can do this: this.BackColor = Color.FromArgb(255, 232, 232); // this should be pink-ish 回答2: With Winforms you can use Form.BackColor to do this. From within the Form's code: BackColor = Color.LightPink; If you mean a WPF Window you can use the Background property. From within the Window's code: Background = Brushes.LightPink; 来源

Can I draw with antialiasing on canvas?

半城伤御伤魂 提交于 2019-12-18 11:38:30
问题 Can I draw with anti-aliasing on canvas? I need my circles and line have smooth edges. 回答1: Drawing operations want Paint . In this Paint you set Paint.setFlags(Paint.ANTI_ALIAS_FLAG) 回答2: Check this out. It fairly uses smooth edges.. http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html The paint properties needed to get anti-aliasing is : mPaint = new Paint(); mPaint.setAntiAlias(true); For drawing use: mPath = new Path(); mPath.reset

Efficient AABB/triangle intersection in C#

你说的曾经没有我的故事 提交于 2019-12-18 11:38:19
问题 Can anyone recommend an efficient port to CSharp of any of the public AABB/triangle intersection algorithms. I've been looking at Moller's approach, described abstractly here, and if I were to port it, I would probably start from this C++ version. This C++ library by Mike Vandelay seems like it could also be a great starting point. ...or... any other "wheel" that can take a triangle of Vector3's and tell me if it intersects with an AABB), relatively efficiently. There seem to be a variety of

How to cut a part of image in C# [duplicate]

痞子三分冷 提交于 2019-12-18 11:21:23
问题 This question already has answers here : How to crop an image using C#? (14 answers) Closed 6 years ago . I have no idea how to cut a rectangle image from other big image. Let's say there is 300 x 600 image.png. I want just to cut a rectangle with X: 10 Y 20 , with 200, height 100 and save it into other file. How I can do it in C#? Thanks!!! 回答1: Check out the Graphics Class on MSDN. Here's an example that will point you in the right direction (notice the Rectangle object): public Bitmap

Specify Width and Height of Plot

筅森魡賤 提交于 2019-12-18 10:53:00
问题 I have a panel containing three plots. How can I use par to specify the width and height of the main panel so it is always at a fixed size? 回答1: I usually set this at the start of my session with windows.options : windows.options(width=10, height=10) # plot away plot(...) If you need to reset to "factory settings": dev.off() windows.options(reset=TRUE) # more plotting plot(...) 回答2: You do that in the device, e.g. x11(width=4, height=6) and similarly for the file-based ones pdf("/tmp/foo.pdf"

How to build perspective projection matrix (no API)

点点圈 提交于 2019-12-18 10:44:25
问题 I develop a simple 3D engine (Without any use of API), successfully transformed my scene into world and view space but have trouble projecting my scene (from view space) using the perspective projection matrix (OpenGL style). I'm not sure about the fov, near and far values and the scene I get is distorted. I hope if someone can direct me how to build and use the perspective projection matrix properly with example codes. Thanks in advance for any help. The matrix build: double f = 1 / Math.Tan