drawing

Removing lagging latency during continuous period of drawing UIBezierPath in Swift

独自空忆成欢 提交于 2019-12-23 19:35:10
问题 The code below draws lines by overriding touches, however lagging begins to occur over a period of continuous non stop drawing. This lagging accumulates and gets worse the longer the finger remains moving across the screen. The result is the CPU nearly maxes out on an actual device (CPU 98%+) and the resulting image looks choppy the longer the drawing continues. Also, when drawing extra fast especially in circles, there is a discrepancy in the paths drawn between the path and temporaryPath

SVG viewBox reversing Y-coordinates

三世轮回 提交于 2019-12-23 12:55:24
问题 I'm using SVG to draw in a HTML page different shapes. These different shapes are retrieved from geometry objects of a spatial database in Microsoft Sql Server. The problem I'm facing is that the system of coords (Svg and Microsoft Sql Server) is different. 0,0 begins in Svg on the top left corner, whereas in Microsoft Sql Server it starts at the bottom left corner. I need to reverse just the Y coords. I'm also using viewBox to display the data properly (for different transformations). Is

setNeedsDisplayInRect called during drawLayer:inContext:

青春壹個敷衍的年華 提交于 2019-12-23 10:08:58
问题 I use a CATiledLayer in my app, and as a result, drawing of that layer is done in a background thread. That is, the drawLayer:inContext: method of my delegate is called from a background thread. The setNeedsDisplayInRect used to invalidate parts of the CATiledLayer is always called from the main thread. Because they are independent threads, it occasionally happens that the setNeedsDisplayInRect is called while the background thread is in the drawLayer:inContext method. I have noticed that the

New area not repaints when user-drawn control size is increased

谁都会走 提交于 2019-12-23 09:58:37
问题 I think I'm missing something trivial here. I derived simple control directly from Control . I'm overriding OnPaint and painting the rectangle ( e.Graphics.DrawRectangle )and a text inside it ( e.Graphics.DrawString ). I did not override any other members. It paints itself well when the control is resized to the smaller size, but when it gets resized to the larger size, new area is not repainted properly. As soon as I resize it to the smaller size again, even if by one pixel, everything

Mystery (concurrency/component drawing?) bug in very simple Swing dice program

丶灬走出姿态 提交于 2019-12-23 09:33:17
问题 Sorry for the poor question title, I'm stumped as to the cause of this bug and didn't know how to phrase the question. I'm learning basic Swing and doing this exercise from the online book Introduction to Programming with Java. I haven't followed the instructions to the letter and instead am trying to do this: have a window that shows a visual representation of two dice when you click on one of the dice, it 'rolls' and shows the new value My implementation: a very basic JDie object that

Finding common outline of multiple polygons

最后都变了- 提交于 2019-12-23 09:27:15
问题 Im trying to find an algorithm for drawing a common outline between multiple polygons. What I mean is like on this picture: We have two rectangles (In my case they will not be rectangles, but polygons with most of their angles as right angle) and Im looking for common outline like a red path on second part of image. The biggest problem as I see it is finding new points which I marked yellow on the second part of image. The polygons will never intersect or touch itselfs. Im storing a polygon

Difference between SuspendLayout and BeginUpdate

蓝咒 提交于 2019-12-23 09:21:29
问题 I do not find a good explanation on what actually the underlying difference is between the two methods Control.SuspendLayout and BeginUpdate (typically seen on list controls like ListView , ComboBox , ListBox etc), other than that they both improve performance. From what I understand: they both suspend drawing until all the items to display are loaded, and repaint after that. typically SuspendLayout is called when controls are added to container controls like Panel , GroupBox etc, while

get angle of a line from horizon

久未见 提交于 2019-12-23 08:35:05
问题 I want to know how to get an angle of a line A-B from horizontal axis X. Other questions in SO do that only between two lines. I'm aware I can always draw second line A-C and calculate but I'm wondering if there's a faster method. EDIT: I'm very sure I'm not doing a premature optimization. 回答1: You can use atan for that. angle = atan((By-Ay)/(Bx-Ax)) 回答2: private double Angulo(int x1, int y1, int x2, int y2) { double degrees; // Avoid divide by zero run values. if (x2 - x1 == 0) { if (y2 > y1

PHP script to draw a spiral?

谁说胖子不能爱 提交于 2019-12-23 06:16:06
问题 Does anybody have a PHP (or other language) script for drawing a spiral. A simple (Archimedean spiral) would be just fine. Of course the principle is simple but coding it in SVG or GD would take some time, so I wonder if somebody has one ready :-) 回答1: See this page: Using GD (imagearc) and PHP to draw spirals (Listing 27.3) 来源: https://stackoverflow.com/questions/2546370/php-script-to-draw-a-spiral

PHP script to draw a spiral?

别来无恙 提交于 2019-12-23 06:15:01
问题 Does anybody have a PHP (or other language) script for drawing a spiral. A simple (Archimedean spiral) would be just fine. Of course the principle is simple but coding it in SVG or GD would take some time, so I wonder if somebody has one ready :-) 回答1: See this page: Using GD (imagearc) and PHP to draw spirals (Listing 27.3) 来源: https://stackoverflow.com/questions/2546370/php-script-to-draw-a-spiral