graphics

how to redraw only one specific layer ? (IOS,SWIFT)

馋奶兔 提交于 2019-12-24 14:08:32
问题 I have my UIView . I draw something in my UIView . I added a CALayer to my UIView . Now I would like my controller to only redraw my added CALayer. How do I do that ? In my actual Code it will redraw the main view. How can I redraw my subview (myshapelayer) ? override func drawRect(rect: CGRect) { var myshapelayer:CAShapeLayer=CAShapeLayer(); var testbezier:UIBezierPath=UIBezierPath(); testbezier.moveToPoint(CGPoint(x: 60, y: 80)); ... ... myshapelayer.strokeColor=UIColor.blueColor().CGColor;

Opengl Billboard matrix

流过昼夜 提交于 2019-12-24 13:44:07
问题 I am writing a viewer for a proprietary mesh & animation format in OpenGL. During rendering a transformation matrix is created for each bone (node) and is applied to the vertices that bone is attached to. It is possible for a bone to be marked as "Billboarded" which as most everyone knows, means it should always face the camera. So the idea is to generate a matrix for that bone which when used to transform the vertices it's attached to, causes the vertices to be billboarded. On my test model

Ocaml's Graphics.open_graph does not work

允我心安 提交于 2019-12-24 13:39:18
问题 I am trying to follow the ocaml manual to draw something. But here is a strange response from Ocaml's toplevel. Anyone sees why? Thanks. # #load "graphics.cma";; # Graphics.open_graph "foo:0";; _X11TransSocketINETConnect() can't get address for foo:6000: nodename nor servname provided, or not known Exception: Graphics.Graphic_failure "Cannot open display foo:0". 回答1: I use Graphics.open_graph " 600x400" , and it works. Note the space before the resolution specification. As to why foo:0 would

unicode symbols printing with ¬ before ° sign when printed using CGContextShowTextAtPoint

此生再无相见时 提交于 2019-12-24 13:27:34
问题 I am printing a ° or a µ on my view using the CGContextShowTextAtPoint call. the line of code is as shown. int number = 100; NSString *theText2 = [NSString stringWithFormat:@"%d°", number]; CGContextShowTextAtPoint(context, 10, 5, [theText2 cStringUsingEncoding:NSUTF8StringEncoding], [theText2 length]); The output of this comes out as "100¬" If I increase the length of the string printed it shows the following "100¬°" The expected output should be: "100°" This surely has to do something with

Generating Polygons from Image (Filled Shapes)

女生的网名这么多〃 提交于 2019-12-24 13:18:31
问题 I'm trying to generate polygons from a preprocessed world map, What i have done so far is: 1: Generated a contour map for each of the countries, it looks like this: From here i filled each of these countries with an random color like this: So far ive tried to just select a random pixel in the countour image and followed the line around until i hit the start point. This did give me a relatively good result, without about 90% accuracy on the polygons, However some countries dissapeared totally.

How to fully unbind a GL_ELEMENT_ARRAY_BUFFER?

走远了吗. 提交于 2019-12-24 13:07:11
问题 I'm working on a multithreaded app that simultaneously renders geometry to multiple FBOs. I'm experiencing a leak (as described on this question). I've been able to narrow it down a little — if I make one change, it stops leaking — but I can't figure out why. On each of 4 threads (each with its own shared context), I'm doing the following each render cycle: // Upload positionBuffer = getUnusedArrayBufferFromPool(); glBindBuffer(GL_ARRAY_BUFFER, positionBuffer); glBufferData(GL_ARRAY_BUFFER,

use graphics.drawText(String, x, y) to draw a string on several lines

浪子不回头ぞ 提交于 2019-12-24 12:51:32
问题 I am making a custom Field representing an image and a label near it. I am drawing the image by graphics.drawBitmap(...) Nw for the text, I am using graphics.drawText(String, x, y); but if the text it bigger than the display, it doesn't return to the line. I tried to add \n but that didn't solve the problem. How can I draw a text that can expand on several lines? Thanks, 回答1: I found a solution to the problem. You can find it below for those who are interested in this question: public void

Java graphics events not occurring in the order I expect them to

Deadly 提交于 2019-12-24 12:48:47
问题 So I'm making a graphical card game. Each card is a JPanel with a button and two images associated with it. I have a flip method, which is the first thing I call in my action listener when a card is clicked on. public void flip() { if(b1.getIcon() == card2) b1.setIcon(card1); else b1.setIcon(card2); revalidate(); repaint(); } However, for some reason the card doesnt flip (meaning the icons don't change) until some point after I call this method. For example, when I put a Thread.sleep after I

How to create a circular bufferedimage rather than creating a rectangular one in Java using Graphics

我只是一个虾纸丫 提交于 2019-12-24 12:37:02
问题 I need to create a bufferedimage (circular type) but I am able to create only rectangular type. Then I want to create a oval inside the bufferedimage with some configurations and finally i want to draw a rectangular icon inside the circular shape which should be inserted on the circular shape and not on the rectangular bufferedimage. Now i am able to do the following BufferedImage img = "SomeImage.png"; BufferedImage bfImage = new BufferedImage(200,200,BufferedImage.TYPE_INT_ARGB); Graphics2D

Generate vector EMF/WMF (Windows Metafile) clipboard content from Qt 4.5

China☆狼群 提交于 2019-12-24 12:20:03
问题 We are moving a large codebase from GDI to QPainter. One thing we used to get on Windows easily was the EMF clipboard format, which enabled customers to manipulate their pasted output in other programs (like Office) in a vector format. It's easy for us to produce bitmaps from Qt into EMF, but that really doesn't give us back the editability of the old format. We can also make mime data from Postscript, which in some programs will retain vector format, but won't allow editability in Office,