I have been trying to draw a round rectangle with a shadow, looked into FloatingActionButton and tried `RoundBorder' like this:
Label labelXXX = new Label("XXX");
labelXXX.getAllStyles().setBorder(RoundBorder.create().color(ColorUtil.WHITE).shadowY(0.0f).shadowOpacity(127));
But the resulting Border looks wrong.
According to the Javadoc of com.codename1.ui.plaf.RoundBorder.shadowY(float)I expected the shadow to be located at the top of the label. Also I expected the round border to fill the labels background and the shadow to be outside of the border.
What do I need to do to create a round rect border that fills the component space and has a shadow outside the component space?
RoundBorder != RoundRectBorder. If you mean to use the latter it's a different class.
Notice that RoundBorder has a rectangle mode which you can activate using a method with the same name that will produce that result.
The shadow can be at the top when you set the Y to 1. Maybe the javadoc isn't clear. This is meant as a directional shadow so the light source is above hence the shadow would be below.
Related
Custom drawing in Gtk3 with Cairo is explained in https://developer.gnome.org/gtk3/stable/ch01s05.html
Here draw_brush in the handler for motion-notify-event draws small rectangles as the mouse is dragged. In the original code there is no other drawing. Suppose I draw a filled blue rectangle in draw_cb by adding the following code:
cairo_set_source_rgb(cr,0.1,0.1,0.8);
cairo_rectangle(cr,80,80,50,50);
cairo_fill(cr);
and similarly another filled red rectangle in clear_surface which is called from configure_event_cb, I get a strange behavior where the blue rectangle is not over-written by draw-brush, but the red rectangle gets over-written, as seen in the picture below:
Can anyone explain this behavior so that I can correctly make custom drawings in the application I am developing.
So, in clear_surface / configure_event_cb, you draw to surface, which is also the surface where the brush draws to. Since the brush is drawn later, it ends up ontop of the red rectangle that you draw here.
In draw_cb, this temporary surface that is used for the drawing is copied to the screen. If you draw a blue rectangle afterwards to the screen, this blue rectangle ends up ontop of what you drew before.
So basically: The reason is the two different targets for drawing that are used here. One is the "actual stuff" on screen, which can disappear at any time. The other is an internal surface created in configure_event_cb that does not go away unexpectedly.
I need to draw a border or rectangle like a bill payment on shop.
For make it's as real, I need to draw a shredding effect with the bottom is a saw-tooth line instead of a normal border.
Would you please to give me some advises?
Forget borders. Terminate the bottom side of the white area as a normal rectangle, but stack immediately at bottom an image (e.g. PNG) with the perforation strip.
That's the easiest way, unless you need something that adapts to the rectangle's width.
I have a pretty standard application with a bar at the bottom. The bar and app are the same background color. My issue is that there is a tiny little line along the edge of the application bar, I can only determine that is it some sort of soft edge that is part of the default style of the ApplicationBar.
Here is an image of the display, note the tiny 1-2 pixel horizontal line:
It appears to be a 1-2 pixel black line with transparency. My main question is, what is this line, is it something I am introducing by accident?
It is by design a 1 pixel gap will be there between ApplicationBar and your ContentGrid. The gap will be visible only when your set the Opacity of the ApplicationBar to 1, So to get rid of the gap You can change the Opacity of the ApplicationBar to 0.99, so that the appbar comes above your ContentGrid.
Obviously you need to make some changes to your ContentGrid so that you can access the part of the Grid that the appbar is occupying.If your grid has ScrollViewer or ListView, it is always recommended to have some extra space after its contents*(may be a empty StackPanel with some height)* which will obviously solve this otherwise if it is a Static layout, you can make use of margin Property.
I have a UserControl which has a quadratic Image as a Child. This Image is at the bottom of the UserControl, and half of it is clipped (e.g. the Control's Height is 400, Image's height is 200 and it is set to y=300).
Now, When I rotate the Image, it is still clipped like the way it was first. Like when rotating around 90 degrees, I suddenly have an Image which is only 100px wide.
It seems like the original clipping which was made because of the bounds of the UserControl, are applied forever.
How do I solve this problem? I hope I explained my problem understandable ;)
How are you rotating the image? If you are rotating using a RenderTransform, then WPF does not re-render what was already displayed on the screen - it simply rotates the pixels.
Instead, rotate the image using a LayoutTransform; this forces WPF to re-render the control given the new area it occupies, which should eliminate the clipping you see.
You can also call InvalidateMeasure() after applying render transform.
I have a requirement to morph from an image (png) to a shape (polygon) in Silverlight 3 as an effect, but of course there is no built in transition or method to do this.
At the moment the best I have is fade one out and the other in, but can anyone suggest a decent alternative that may work or look better?
Regards
Moo
In Blend:
Create a rectangle. Set stroke to No Brush and Fill to Tile Brush.
For the ImageBrush of the Tile Brush, select your image.
In the object browser, select the rectangle, right click > Path > Convert to Path.
Use the pen tool to add some points to the path.
Add a storyboard.
Add a keyframe at 1 second. Blend will go into record mode
Use the direct selection tool to move the points into the polygon shape you want. Test out your animation.
At this point, the image morphs into a shape, but the image is still there. If you need to remove the image as well as morph it:
In your storyboard, at the keyframe at 1 second, change the opacity to 0.
Create a copy of the rectangle, but make sure fill is set to No Brush and Stroke is set to a color and width. Set the opacity to 0.
Add points, and mimic the animation you just set up for the image's rectangle.
Add a keyframe at 1 second for this element. In record mode, change the opacity to 100%.
The end result will be both paths morphing, the one with the image fading out while the one with no fill fading in.
I'm not a silverlight programmer, and don't know the details of what you want to do, so this is just a shot in the dark, but... if the shape you want the image to morph to is always going to have the same initial visual appearance (or some limited set of appearances) you might try morphing from the original image to an image of that shape, and then swapping the image that's the morph target for the geometry once you're done the morph. Course whether that would work or not is very dependent on the details of what you're doing. Sorry if you've already considered that and ruled it out.
You could possibly morph the image brush to the path of the shape by using an appropriate projection matrix. Or render a shape using the image brush and then morph that shape to the target shape, i.e. go from a rectangle to the target shape but using the image brush as the shape background. You may need to still warp the image brush somehow though.
An example of rendering a warped image is here in Charles Petzold's blog.