As I given an URL below, In that example, there is option to draw a line when drag by mouse,But I need a button and when click over that, draw a line over graph at 60 degree angle. I am using highcharts.js.
Visit JSFiddle jsfiddle.net/BlackLabel/N6GR9/
You can take a look at this JSFiddle.
chart.renderer.path
is a method you can use for drawing paths in general and a line in this case.
Related
Corner points in fontforge (seemingly also known as "coins", shown as squares in the UI), can have zero, one, or two handles to control the direction of the outgoing lines. This fact is nicely explained in the manual, but I cannot find any hints on how to control the number of handles.
How do I change the number of Bézier handles of a corner point?
In my specific case I have a straight line between two corners, and I would like to change this line to "bulge outwards" a bit. I tried to add a "curve point" between the two corners, but this gives me a strange curve point with no handles, which seems to be functionally identical to just another corner.
The simplest way to make a line bulge is to grab the line and drag (ensure the surrounding corner points are not selected first). This will immediately turn it from a line into a curve, and create control points. If you want to turn it back into a straight line, select the surrounding corner points then right-click the line and choose "Make Line".
You could equally add a curve point between the corners (CTRL-ALT-click where you want to add) and then merge it back out of existence using CTRL-M. This will leave the line as is, but with control points available.
Note that control points won't display unless you have selected an adjacent corner point or curve point. You can make them always display by selecting View>Show>Control Points (Always).
Very occasionally you may encounter what looks like a line but is actually a curve in which the control points coincide exactly with the corner points. The above methods will work fine in this situation too.
I need to create QGraphicsItem for circle and I'm getting the output as the one which I attached along with my question. How do I draw smooth circle with good quality ? Above is my code and and above is my output. Please help me regarding this. I've tried Antialiasing and SmoothPixMapTransform of the QGraphicsView using QPainter property. But, still the result is same.
set Anti-aliasing render hint for view
http://doc.qt.io/qt-5/qgraphicsview.html#renderHints-prop
Looks like your default rendering engine doesn't support antialiasing.
Try the -graphicssystem raster command line parameter to force the raster (software) rendering.
Try also the "basicdrawing" example of QtCreator to check how widgets are rendered.
See setStartAngle() and setSpanAngle() documentation:
Sets the start angle for an ellipse segment to angle, which is in 16ths of a degree.
Sets the span angle for an ellipse segment to angle, which is in 16ths of a degree.
It's highly probable that your 20 and 45 (e.g. 1.25° and 2.8125°) are not what you want.
To enable antialiasing, you should add the following line:
view->setRenderHints(QPainter::Antialiasing);
Result:
Antialiased
Normal
Currently I'm using "Douglas Peucker" algorithm.
My problem is that when I'm drawing,the previously drawn lines are also changing which of course not realistic. Is there other alternative algorithm to minimize the saved points but not altering the previous drawn points or other way to alter "Douglas Peucker" to fit my need?
Give your pencil drawing tool 2 optional methods for drawing:
Draw a new point on the path using mousemove (which is your current freeform method). This option will let the user add many points which will allow them to be very detailed in their drawing.
Draw a new point on the path only upon mousedown. This option simply connects the previous point on the path to the newly clicked point. This option will let the user add just a few very straight lines which will allow them to outline figures with long running straight edges.
If you are concerned about the freeform path changing while the user is drawing you can apply the simplifying algorithm just once after they have stopped moving the mouse for 1 second.
If you specify the Douglas-Peucker algorithm use a high bias for accuracy then the simplified path will remain quite true to the unsimplified path.
BTW, if you want to draw splines through your points then check out this nice previous post: how to draw smooth curve through N points using javascript HTML5 canvas?
If I have an object performing this CAKeyframe Animation path (it is just an oval shape in the upper region of an iphone..
UIBezierPath *trackPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(20, 100, 280, 150)];
Now imagine that at anytime during this paths travels I want to create a smooth path from its current position at a point in time and some point at the bottom of the screen.
By the way I am assuming that once I have a path I can stop the current CAKeyframeAnimation and add this path to a new CAKeyframe animation, but maybe if this is incorrect you can give me pointers here as well please.
So I said to myself "Self.....it looks like you are going to have to answer this one yourself as nobody even wants to edit it or say that it is a duplicate......"
So I was hoping for some easier or ready made way to do this. From what I have found there is no easy way. It seems the steps are going to be;
get the current position of the animated layer
calculate yourself with all your own code a nice smooth curve
add this path to an animation and animate it.
As for the calculation of a Bezier Curve I am still looking to find some class or code where points can be plugged into it and the two control points are produced for the UIBezier class to produce a curve.
In my case I am going to only animate "out" of my above questioned shape a determined points and thus have ready made smooth curves which I have prepared.
Animating a smooth exit from an oval at any point is very complicated and In my case just not worth it. So I have not done that.
today I have a (simple) rendering problem for you. My current project gets datas from a file to generate a SVG file. Drawing things as polygon is pretty easy thanks to the SVG format, but I have a single problem: some of my polygons are in AND out of the page (meaning that some parts of them are displayed while the rest is not shown due to the fact they are out of the display limit). In order to optimize the final SVG file I need to reduce my polygon to a simpler form.
Consider the grey rectangle as my page.
Consider the green polygon as the thing I actually draw.
First picture shows you the thing that I actually have while the second picture shows you the final result I want to have.
First I thought to reduce my polygon in simple triangles in order to only draw points in the display limits. But I think a simpler solution exists... if you have it do not hesitate to share it with me :)
EDIT:
I have this tricky case to handle as well :
Thank you.
Clipping a polygon with a rectangle. We reduce this problem to
clipping a polygon with a line. We reduce this to an even simpler problem:
clipping one edge of a polygon with a line. Which is really just
Finding the intersection of a line segment with a line (if it exists).
The last problem is pretty easy, considering that your lines are vertical or horizontal. Is that enough?