Does anyone know of a way to resize 2 windows to 50% of the screen using Selenium? Or something similar if it can't do it. I'm using Python and Chromium but again, if there is something better I am open to ideas.
Use below code for 50%
driver.execute_script("document.body.style.zoom = '0.50'")
0.50 means - 50% Zoom
1.50 means - 150% Zoom
You can get the window size by
Dimension size = driver.manage().window().getSize();
int height = size.getHeight();
int width = size.getWidth();
And set the window size by
driver.set_window_position(0, 0)
driver.set_window_size(width/2, height);
Related
If I render to a bitmap then the bitmap has a specific number of pixels and a DPI. That combination makes it easy to draw a square that is 1" x 1" - I render lines for each side that are DPI pixels long.
When I create a SVG, I think it should still be able to be set this way. Where I set the units per inch and also the size in those units of the object as a whole. Yes you can zoom on a SVG file as it's all vectors, but it should still have a 100% zoom size to render to.
In my case I am using EMUs for my units. So 914400 units/inch. So question #1 is, how do I set the scaling using Batik. For a bitmap it's:
AffineTransform scaleToEmus = AffineTransform.getScaleInstance(dpi / (float) DrawingSurface.EPI, dpi / (float) DrawingSurface.EPI);
graphics.transform(scaleToEmus);
But there is no dpi equivalent for SVG.
And then for a given width & height that is in EMUs, do I set the size (or maximum extent) of the image using:
svgGraphics.setSVGCanvasSize(new Dimension(width, height));
I think I'm not fully understanding SVG, or at least Batik as I don't see how to set the units to render at for a 100% zoom.
I'm playing about with the most recent NSDocument in a Swift document-based-app. One thing that's a bit odd is that the starting location for a new window is near the bottom of the screen.
Playing with the Storyboard a bit, its not clear how to use the built-in settings to come up with a reasonable "near the top" selection - the setting moves up from the bottom, not down from the top, so the position would change depending on the screen size?
I assume there's a position mechanism I can hook, but it's not obvious in the shell code that's supplied. Any hints?
OS X coordinate system is flipped in contrast to iOS. So the 0,0 is the bottom left corner.
You can calculate the position of your window in similar manner (any screen size)
CGFloat width = NSWidth([self.window screen].frame);
CGFloat height = NSHeight([self.window screen].frame);
[self.window setFrame:NSMakeRect(100, height - 100, width, height) display:YES];
Most easiest is to set initial height to 900 and forget about it and enable window restoration -> this will cause to open the window where it previously was and this is where it user wants.
Select your window in Storyboard. And fill initial position coordinates
I think the phone uses the layout-hdpi file but this doesn't seem right, mostly because its dimensions(540 x 960) are not what I'm used to seeing(480 x 800) for layout-hdpi phones. So what is the actually layout file used? Also, if it is layout-hdpi phone how can I stretch an icon that has a width of 480 to 540? Would I programmatically have to test the phone's dimensions and then expand the drawable-hdpi file to fit the various device dimensions? I looked at this link but they never specified what layout file was used.
Yes, HTC Evo 3d use drawable-hdpi images. You should have to put the Layout file also. Put the same file into layout-hdpi.
Now create the Emulator of the Resolution 540 X 960. And test the App in it. There should be minor difference between normal hdpi and HTC Evo Screen resolution. Manualy test it.
I am getting same trouble before some days. What i have done is: I am going to check the resolution of the devide screen size at run time. And if the Resolution is compare to that HTC Evo 3d then it will set the height and Width of the All Images at run time that fit to the HTC Screen Resolution.
That was the Best Solution i found till today to Make app for HTC Evo 3d.
For Checking the Resolution at run-time you can use this:
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
display.getMetrics(dm);
int width = display.getWidth();
int height = display.getHeight();
if((height==960) && (width == 540)){
// Do change the Image Height or Width or position
}
Enjoy. :)
I'm trying to display text on a Windows control, rotated by 90 degrees, so that it reads from 'bottom to top' so to speak; basically it's the label on the Y axis of a graph.
I got my text to display vertically by changing my coordinate system for the DC by using SetGraphicsMode(GM_ADVANCED) and then using
XFORM transform;
const double angle = 90 * (boost::math::constants::pi<double>() / 180);
transform.eM11 = (FLOAT)cos(angle);
transform.eM12 = (FLOAT)(-sin(angle));
transform.eM21 = (FLOAT)sin(angle);
transform.eM22 = (FLOAT)cos(angle);
transform.eDx = 0.0;
transform.eDy = 0.0;
dc.SetWorldTransform(&transform);
Now when I run my program, the rotated text looks different from the same text when it's shown 'normally' (horizontally). I've tried with a fixed-width (system) font and the default WinXP font. The system font comes out look anti-aliased and the other one looks almost as if it's being drawn in a 1-pixel smaller font than the horizontal version, although they are drawn using the same DC and with no font changes in between. It looks as if Windows detects that I'm drawing a font not along the normal (0 degrees) axis and that it's trying to 'optimize' by anti-aliasing.
Now I don't want any of that. I just want to same text that I draw horizontally to be drawn exactly the same, except 90 degrees rotated, which is possible since it's a rotation of exactly 90 degrees. Does anyone know what's going on and whether I can change this easily to work as I want? I'd hate to have gone through all this trouble and finding up that I will have to resort to rendering to an off-screen bitmap, rotating it using a simple pixel-by-pixel rotation and having to bitblt that into my control :(
Have you tried setting the nEscapement and nOrientation parameters when you create the font instead of using SetWorldTransform? See CreateFont for details.
Using Allegro 5, how do initialize a game in fullscreen mode so that it respects the format of the screen (widescreen 16:9 vs normal 3:4)
al_create_display (w, h)
Let's you select any ratio you want. For example you can set 640x480, regardless of the screen size. But it will look weird on a widescreen monitor.
How do you know which ratio to use?
Hm, I can answer this as well - use al_get_monitor_info().
al_get_monitor_info(0, &info);
w = info.x2 - info.x1; /* Assume this is 1366 */
h = info.y2 - info.y1; /* Assume this is 768 */
al_create_display(w, h);
Now you can either render everything in a 640x480 rectangle centered within 1366x768 to make it appear pixel-perfect, or alternatively scale your graphics up by 768/480 and keep two black bars to the left and right. If you use OpenGL for rendering, both are very easy to do by simply altering the projection matrix.