graphics

Lines using the R grid package

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 14:37:26
问题 I am using R with cygwin and am trying to plot some basic graphics. Here is a simple example from one of Paul Murrell's papers: library(grid) x <- rnorm(50) y <- x + rnorm(50, 1, 2) rx <- range(x) dx <- diff(rx) ry <- range(y) dy <- diff(ry) max <- max(rx, ry) min <- min(rx, ry) r <- c(min(rx, ry), max(rx, ry)) d <- diff(r) scale <- r + c(-1, 1) * d * 0.05 extscale <- c(min(scale), max(scale) + diff(scale) * 1/3) lay <- grid.layout(2, 2, widths = unit(c(3, 1), "inches"), heights = unit(c(1, 3

problem displaying mouse coordinates on the screen in java

本秂侑毒 提交于 2019-12-13 13:59:32
问题 I'm trying to display mouse coordinates (math coordinates) in my JPanel , but i get each coordinates on top of the other ,can' figure out why . here's my code : import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.applet.*; import javax.swing.JPanel; import javax.swing.event.MouseInputAdapter; public class drawarea extends JPanel { int n; private Point mouseCoords = null; int UNIT = 20; drawarea() { super(); setBackground

class can't be instantiated

落爺英雄遲暮 提交于 2019-12-13 13:47:37
问题 I have a problem with java applet and graphics. I'm trying to run it in Eclipse and it fails. Im new in java and i hope you can help me. I have two files: Say.java and SayWhat.java. Say.java: public class Say { SayWhat word = new SayWhat("Hello World"); } SayWhat.java: import java.applet.Applet; import java.awt.Graphics; @SuppressWarnings("serial") public class SayWhat extends Applet { Graphics g; String what; public SayWhat(String what) { this.what=what; } public void paint(Graphics g){ g

SSE alpha blending for pre-multiplied ARGB

两盒软妹~` 提交于 2019-12-13 13:39:45
问题 I'm trying to write an SSE-enabled alpha compositor, this is what I've come up with. First, the code to blend two vectors of 4-pixels each: // alpha blend two 128-bit (16 byte) SSE vectors containing 4 pre-multiplied ARGB values each // __attribute__((always_inline)) static inline __m128i blend4(__m128i under, __m128i over) { // shuffle masks for alpha and 255 vector for 255-alpha // // NOTE: storing static __m128i here with _mm_set_si128 was _very_ slow, compiler doesn't seem // to know it

Calculating the vertex normals of a quad

好久不见. 提交于 2019-12-13 13:38:31
问题 Lets say that i have the following array : float QuadVertices[4 * 2]; float QuadNormals[4 * 2]; Which i fill this way : //Fill vertices for a 2d quad Renderer->FillVertices(QuadVertices,GL_QUADS,x,y,width,height); Now at this point everything is ok i can render a quad , texture it , stretch it and all that. But now i want to calculate the normals of the quad : for (int i = 0; i < 8;i++) { QuadNormals[i] = ?? } BUT i can't figure out how on earth i am supposed to calculate the normals of a

c++ Having multiple graphics options

我的未来我决定 提交于 2019-12-13 13:25:11
问题 Currently my app uses just Direct3D9 for graphics, however in the future I' m planning to extend this to D3D10 and possibly OpenGL. The question is how can I do this in a tidy way? At present there are various Render methods in my code void Render(boost::function<void()> &Call) { D3dDevice->BeginScene(); Call(); D3dDevice->EndScene(); D3dDevice->Present(0,0,0,0); } The function passed then depends on the exact state, eg MainMenu->Render, Loading->Render, etc. These will then oftern call the

Getting drawable area of an AWT frame in Mac OS X?

只谈情不闲聊 提交于 2019-12-13 13:25:00
问题 I have subclassed java.awt.Frame and have overridden the paint() method as I wish to draw the entire contents of the window manually. However, on the graphics object, (0,0) corresponds to the upper left hand corner of the window inside the title bar decoration, not the first drawable pixel. Can I determine the co-ordinate of the first drawable pixel (ie, the height of the decoration) in a cross-platform manner, avoiding using a Mac OS X-specific fudge factor? Will I be forced to nest a Panel

Implementing Double Buffering in Java

青春壹個敷衍的年華 提交于 2019-12-13 13:07:43
问题 I have a simple Java JFrame canvas. I am updating what is on the screen every half second or so, and have flickering. I want to implement double buffering to eliminate the flickering, but I am fairly new to Java and am unfamiliar with how to do so. I have found some examples, but not sure how to implement their methods into mine. Below is the basic setup of how I have things now. This is not my exact code- just an example of the basic setup. Thanks for any push in the right direction! public

Subtractive Filter on Android ImageView (Cut-out a feathered oval from an image or view object)

南楼画角 提交于 2019-12-13 12:48:54
问题 I'm trying to figure out how to "cut-out a feathered hole" in an ImageView. The reasoning is, I am creating a tutorial, and I want the whole screen dim. That's easy enough to do by placing a black image with alpha around 50%. Next I want to cut a hole into that overlay, so you can more clearly see what's underneath it. The goal in mind is to highlight buttons and things for the user to click on, so they learn what to do. When I did this before in ActionScript / Flash, it was easy to just put

How to draw the middle half of a sphere (in code)

回眸只為那壹抹淺笑 提交于 2019-12-13 12:44:03
问题 I'm trying to create the middle half of a sphere. Basically to create a sphere, stack numbers and slice numbers are given, and there are two variables phi (for slices) and theta (for stacks) responsible for how much to progress. And the process is divided into creating bottom cap, body, and top cap (as seen below). To achieve middle half ( theta of middle 50% as below), we need to omit the caps, and somehow modify the body. I was playing around with stack numbers ( 1/4*stackNumbers to 3/4