i have got this beautiful looking image:
I decided to use the PolygonSprite class in LiGgdx to display a part of that Image.
It ended up looking like that:
As you can see the very left corner of my image is visible.
Here comes my question:
What can i do to display a larger part of that image inside the polygonSprite above, without changing the polygonSprite's size ?
I do really appreciate any answer and please don't hesitate to ask if something isn't clear.
I've never used it myself, but looking at the documentation it looks like this: you have to create the polygonsprite with a correct polygonregion (vertices with pixel coordinates of the texture) and then use setSize to "scale" it to the size you want to display it (world/viewport coordinates).
Related
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.
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
Was just wondering how you would be able to check each pixel, from top of your screen to bottom (or just a 500x500 rectangle) for a pattern of pixels in it. Example look through all the pixels, and see if there is 20 red pixels in a row (Search the screen for a red box).
Sorry for the terrible description, let me know and ill try to make it more specific.
What you are trying to do is called Template Matching in the Image Processing community, you should first check this.
For the implementation part, you can access the pixels of BufferedImage (using getRGB/getRGBs methods), or even better you can use JAI or JavaCV if you want to do anything serious.
What is the best way to edit singular pixels of an texture multiple times per frame? I have tried using a couple ways to no avail. What is the most optimal way to do this? I have tried using Intermediate mode and drawing each quad, thought, this is really slow.
Edit:
I forgot to mention that I am doing an unusual "fog of war" system. This system doesn't let you see around walls but instead acts like a 2D ray traced shadow. I want these shadows to be pixelated as this is part of the style of the game. I am trying to find the best way to do a form of a shadow map that I can overlay over the world to show what you can see.
I recommend using a Pixel Buffer Object.
So this is what I want to do:
I have an image from which I want to take just a part of it. Let's say the image is 50px by 50px, I want to take the top left corner only 10px by 10px. so x=0, y=0, w=10, h=10
Then I want to paint this top corner, but in size 100px by 100px.
Does anyone know if this is possible? If so how would I go about it?
Thanks.
First take a look at getClip. This will allow you to draw a part of your image.
Regarding scaling - you will have to write / find a procedure that does that as I know J2ME MIDP doesn't have any methods that offer this.
Google search finds this (untested by me)
http://willperone.net/Code/codescaling.php