How to Draw a continuous line on touch path in libgdx? - java

I tried using pixmap , but every time i draw a path and increaase drag speed , it shows space betweeen two pixmap circles.
I also tried by saving touch points in an array and drawind all the points by shaperenderer but same thing happened.
I need to draw a smooth line like in some image editor apps.
Right now using this method.
while (cIter.hasNext()) {
penpoint = cIter.next();
shapeRenderer.circle(penpoint.getPosition().x,
penpoint.getPosition().y, 3);
}
but it shows like this.
https://s3.amazonaws.com/pushbullet-uploads/ujCRdpmszeu-lp4uLBpI5MftwHBvmk58QP4w4mrzfkJx/Screenshot_2014-12-14-15-23-41.png

do not know if this is what you want, but maybe you can use it for whatever you want to do, hope it helps.
https://github.com/libgdx/libgdx/wiki/Path-interface-%26-Splines
https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/PathTest.java
P.S:maybe you can look on Beizer curves
https://www.google.es/?gws_rd=ssl#q=http://devmag.org.za+/2011/04/05+/bzier-curves-a-tutorial/

Related

LibGDX - draw curved Label

I want to draw a curved Label, But don't know how. Is there a way to get a curved Label?
For example, I have this background. I need to draw the 'ARCADIAN DEER' not straight, but curved. Any suggestions on what way I can think?
This is probably not the best way, but probably the easiest. Assuming you are using Scene2D - make each letter it's own Label, then make a custom helper Group to position and rotate the labels as you like. You might even be able to use a HorizontalGroup for automatic placement along X.

How do I make 2d- Flashlight effect in Processing 3

For reference the effect I'm going for is this:
I'm working in Processing 3, NOT p5.js.
I've looked around processing forums, but i can't find anything that works in the current version or doesn't use PGraphics and a mask which from what I've read can be expensive to use.
My current ideas and implementations have resulted to drawing shapes around the player and filling the gaps in with a circles with no fill that has a large stroke weight.
Does anyone know of any methods to easily and inexpensively draw a black background over everything except a small circular area?
If this is the wrong place to ask this question just send me on my way I guess, but please be nice. Thank you:)
You could create an image (or PGraphics) that consists of mostly black, with a transparent circle in it. This is called image masking or alpha compositing. Doing a Google image search for "alpha composite" returns a bunch of the images I'm talking about.
Anyway, after you have the image, it's just a matter of drawing it on top of your scene wherever the player is. You might also use the PImage#mask() function. More info can be found in the reference.

opencv java - detect all the rectangles and fill them with an image

I am currently working on a solution for an automatic image edit.
And I have used Canny Edge Detection and Closing.
But What I ultimately want to accomplish is to find all the rectangles from blueprint and fill them with an image what I have.
I want to know the process that I need to take, not the exact code or solution!
Please suggest me what steps should I take to accomplish it, thx.
Image that has the rectangles
Image that needs to go into all the rectangles
what i have done so far
2018-02-12 EDITTED(clean rectangle detected)
// I have done finding the rectangles and drawing lines over them, but the result is not really reliable than I expected(it draws line on rectangles those are not a parking space), and I do not know how to put an image on those rectangle instead of drawing line on them. please help me out!
P.S : Only in JAVA please !
In your case, you don't need Canny. Your image is really clean and edges are really visible already. A simple Threshold, will work better.
For rectangle detection take a look at this example (included with opencv) that uses findcontours and checks the angles: https://github.com/opencv/opencv/blob/master/samples/cpp/squares.cpp
In your case, you can skip the Canny step because you don't have gradients. You may need to modify the filtering, like side dimensions for your case.
Once the rectangles look good, you just need to copy your image in the location. If rectangles are rotated, you will have to rotate your image as well.
EDIT:
To copy the small image onto the big image you can do the following
Mat submatImg = bigImage.submat(new Rect(x, y, smallImage.width(), smallImage.height());
smallImage.copyTo(submatImg);
If you need to do resizing and rotations, take a look at geometric transformations

How to change the position of a view?

I have two views called x and y they are both black lines (for example I made the height of the x line is 1dp and width 230dp and as background filled with the color black).
Now i want to move the position of the lines programmatically (for example I want the y line 50dp to the right of the orginal position).
Can someone help me how to do this?
I have tried things such as setpadding but the line doesn't move.
Thanks in advance!
(ps: my minimum sdk is set for 7 so i can't use the newest api's).
Old Answer
Have a look at the Absolute Layout, it allows you to position
child elements using x, y coordinates. It is deprecated but it's the
only way in Android to do real x,y coordinate positioning.
I would ask what the main point behind what you are trying to do is
though? It sounds like you started with a goal, were led down a path
and now are asking how to get to the end of that path, rather than
asking how to do what you need to do.
Edited
For drawing graphs have a look instead at https://stackoverflow.com/questions/2271248/how-to-draw-charts-in-android.
Using a Layout class to draw a chart will only lead to a really slow app, since the layout classes are designed for creating relatively static layouts, not drawing full graphics.
Instead use either the Canvas and draw your drawables yourself or use the graphing packages listed in the SO question I linked above.

Drawing animation path on google map in Android

I'm trying to draw path on the map in Android and I want that the path line is an animation. I can draw lines in any static color (blue, red etc.) but not an animation. The line must be an animation. This link explains what I want to do.
Tugrul.
I believe this is not easy thing to do, but if you are using canvas to draw the path, you can use the functions canvas.translate() canvas.rotate() canvas.scale() with some sort of timers to achieve what you need, if you are using something else please state it.

Categories

Resources