I'm asking myself how to create a long shadow programmatically. Here its already working.
I would like to provide this functionality in a Java library (Android and maybe in JavaFX). What amazes me the most is the fact that the shadow creation works for a given text and also a image file.
If someone has any idea / advice how to get this working, please let me know, thanks in advance.
To draw black pixels in a loop which increments X and Y is the easiest part, I guess.
You have to define a line (red line, see Bresenham) and move the line across your whole image...
in my example: we move move horizontally
1) set the line to the very left (maybe even outside the visible scope).
2) set the line color to 'light'.
3) walk along each pixel from the line and draw the pixel with the line color. if the pixel hits a visible pixel (green rectangle), change the line color to 'shadow'
4) move the line one pixel to the right
5) if(not reached_right_border) goto 1
6) redraw text/image over the shadow
Related
I have a camera that is pointing on a road. Right in boarder of this road, there is a big grey floor lamp. On this floor lamp i will paint some horizontal red lines.
I want to make a java application that can count the number of red lines.
I could simply get an image, with a for loop move on each pixel and show if it's red... but this will be really not optimized. I can specify that the lines are perpendicular to the image. To optimize I could simply move in y in the center of the image and count each time the color goes from gray to red?
do you have any idea of library that i can use, or an image processing process that make it better ?
thanx for help
EDIT :
From that image : image1
i can have this result : result
how coul'd i count the number of line
so at this moment i make some tries into my office.
Consider this wall is a floor lamp
on this picture you can see the calibrated pattern
And here you have the pattern used as overlay
Each line is separted with 5cm. when it snows, the bottom lines will gradually be hidden. So I can count the number of lines from the top to define the height of the snow.
I have the following problem:
I have written a plugin for ImageJ, which sets specific pixels (the blue ones = cells) to the color red.
Result after setting the blue pixels red
Now I also want to set also all the pixels, which are inside a marked area, to red.
So I don't want to have any holes.
Example for a hole:
I searched the web for hours, but I didn't find anything. I hope somebody knows how I should deal with this issue.
Perhaps it is because the value of blue pixels varies. A better way would be to detect edges and then use flood fill algorithm to fill in the regions inside the boundary.
Found one sample code here http://imagej.net/Level_Sets with github source https://github.com/fiji/level_sets/.
I am using a Java application to display an image on the screen. I also am using an eye-tracker device which records the absolute pixel X,Y locations where the person is looking on the screen.
However, what I need to do is convert these X,Y coordinates from the screen positions into the X,Y locations of the image. In other words, somehow I need to figure out that (just an example) 482, 458 translates to pixel 1,1 (the upper left pixel) of the image.
How can I determine the image's placement on the screen (not relative to anything)?
I saw a few posts about "getComponentLocation" and some other APIs, but in my experimentation with these, they seem to be giving coordinates relative to the window. I have also had problems with that because the 1,1 coordinate that they give is within the window, and there is actually a bar at the top of the window (that has the title and the close and minimize buttons) whose width I do not know, so I cannot easily translate.
Surely there must be a way to get the absolute pixel location on the screen of a component?
If we are talking about Swing/AWT application than class java.awt.Component has method getLocationOnScreen which seemed to do what you want
And yes as #RealSkeptic mentioned in comments to question:
SwingUtilities.html#convertPointFromScreen
will do all this work for you considering components hierarchy
I have a line drawn using Canvas. Let's name the two endpoints as A and B. I also have a point. I moved it from point A to point B using TranslateAnimation. Now, what I want is, to change color of the line as the point moves. I can surely change color of the line as a whole. But how to color it according to the movement of the point? Any help would be appreciated.
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.