graphics

How to delete a drawn circle in c# windows form?

帅比萌擦擦* 提交于 2019-12-17 18:43:56
问题 I have drawn a circle in windows form Pen pen = new Pen(Color.Black, 3); Graphics gr = this.CreateGraphics(); gr.DrawEllipse(pen, 5,5,20,20); How to delete it... 回答1: You can invalidate the draw region you want to refresh for example: this.Invalidate(); on the form... 回答2: You have to clear your Graphic: Graphics.Clear(); But all drawn figures will be cleared. Simply, you will then need to redraw all figures except that circle. Also, you can use the Invalidate method: Control.Invalidate() It

How to color a pixel?

懵懂的女人 提交于 2019-12-17 18:38:01
问题 I have to create a simple 2D animation without using various primitives for drawing line, circle etc for the purpose. It has to be done by manipulating pixels and implementing one of the algorithms for drawing line, circle etc by coloring pixels. I thought of using Turbo C for the purpose, but I use ubuntu. So I tried using dosbox to install and run turbo C but to no avail. Now my only option is Java. Is it possible to manipulate pixels in Java? I couldn't find myself any good tutorials for

How do glPushMatrix() and glPopMatrix() keep the scene the same?

筅森魡賤 提交于 2019-12-17 18:29:24
问题 I found some code online which will move a box across the screen, then reset it after the box hits the end of the screen. Here is the code: void display(void) { int sign = 1; if (lastFrameTime == 0) { /* * sets lastFrameTime to be the number of milliseconds since * Init() was called; */ lastFrameTime = glutGet(GLUT_ELAPSED_TIME); } int now = glutGet(GLUT_ELAPSED_TIME); int elapsedMilliseconds = now - lastFrameTime; float elapsedTime = float(elapsedMilliseconds) / 1000.0f; lastFrameTime = now;

Building a 9 patch drawable at runtime

末鹿安然 提交于 2019-12-17 18:24:25
问题 I am successfully building a 9patch drawable at runtime on Android 3.0+ using the excellent gist provided by Brian Griffey (found here). Essentially I load the raw (no patches) graphic file from the network and the filename contains the cap insets that I need to use in order to scale the image accordingly. I then use these values with the class found above and apply the image as a background to a variety of elements (such as TextView , ImageButton , Button , ViewGroup , etc). This works

blend two images on a javascript canvas

孤者浪人 提交于 2019-12-17 18:23:49
问题 How do you blend two arrays of pixel data to create one image? with the option of using different blending modes? 回答1: Pixastic is a special framework for advanced use of canvas, here are blending examples: http://www.pixastic.com/lib/docs/actions/blend/ If you would like do this alone, you can extract pixel data from 2 images, blend it with a mathematical equation, and put into a canvas. Here is information how to get and put pixel data from/to canvas: http://ajaxian.com/archives/canvas

Enabling WebGL support for Android WebView

老子叫甜甜 提交于 2019-12-17 18:23:32
问题 I need to display WebGL graphics in my webview. Is there any way to modify Android WebView to enable WebGL. If yes, How? 回答1: WebGL was not supported in WebViews before Android Lollipop. In KitKat, Android switched to Chromium as the native WebView implementation, but it is locked to Chromium 33, with no WebGL. In Lollipop, WebView is updated via the Play Store, and now supports WebGL. (source: https://developer.chrome.com/multidevice/webview/overview) Trying to extend WebView to support it

DirectX 11 framebuffer capture (C++, no Win32 or D3DX)

我的未来我决定 提交于 2019-12-17 17:58:18
问题 I would like to capture the contents of my front or back buffer using DirectX 11 into an array of bytes which I can then use as a texture or as a source for creating a file. I have a swap chain setup, lots of rendering happening and the following code so far - which I make sure to call after the call to Present. ID3D11Texture2D* pSurface; HRESULT hr = m_swapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), reinterpret_cast< void** >( &pSurface ) ); if( pSurface ) { const int width = static

Convert a quadratic bezier to a cubic one

两盒软妹~` 提交于 2019-12-17 17:49:30
问题 What is the algorithm to convert a quadratic bezier (with 3 points) to a cubic one (with 4 points)? 回答1: From http://fontforge.sourceforge.net/bezier.html: Any quadratic spline can be expressed as a cubic (where the cubic term is zero). The end points of the cubic will be the same as the quadratic's. CP 0 = QP 0 CP 3 = QP 2 The two control points for the cubic are: CP 1 = QP 0 + 2/3 *(QP 1 -QP 0 ) CP 2 = QP 2 + 2/3 *(QP 1 -QP 2 ) ...There is a slight error introduced due to rounding, but it

How to label histogram bars with data values or percents in R

只谈情不闲聊 提交于 2019-12-17 17:27:30
问题 I'd like to label each bar of a histogram with either the number of counts in that bin or the percent of total counts that are in that bin. I'm sure there must be a way to do this, but I haven't been able to find it. This page has a couple of pictures of SAS histograms that do basically what I'm trying to do (but the site doesn't seem to have R versions): http://www.ats.ucla.edu/stat/sas/faq/histogram_anno.htm If possible, it would also be nice to have the flexibility to put the labels above

Bump-map a sphere with a texture map

自作多情 提交于 2019-12-17 17:23:51
问题 We would like to bump-map a sphere with a texture map. However, the surface of the sphere has an area that is 10 times the area of the texture map(area for both in pixels). Describe different ways in which the texture map can be used for bump mapping. 回答1: usually rectangle texture is used for spheres texture (u,v) coordinates are used as angles for spherical coordinates. The result is that texels are bigger near equator and smaller near poles. At poles all the texels merge to single pixel.