Can I change the screen resolution in nightmarejs? (Not a viewportSize)
For example, how it works in Casperjs:
var casper = require("casper").create({
onPageInitialized: function (page) {
page.evaluate(function () {
window.screen = {
width: 1920,
height: 1080
};
});
}
});
Many thanks!
(This answer is pulled from my original answer in Nightmare #699.)
I'm not certain, but I don't think so, at least not directly. Electron's screen resolution depends on the framebuffer it's rendering to. You could use something like xvfb-run to alter the framebuffer (#224 touches on this, although for an entirely different reason).
Without more information, it's tough to answer your question. If you provide more information about what you're trying to accomplish, I'll update this answer.
Nightmare is based on electron. Refer similar question and my answer here
Related
I've developed a custom receiver which works very nicely, however the rendering of the graphic on the album art image looks weird. I've also tried the "styled media receiver", just to be sure that I haven't screwed anything up - same result.
Anyone else seen this (check the image below)? The channel logo is a transparent PNG.
Screenshot of bug
let shadowRootElement = document.querySelector( 'cast-media-player' ).shadowRoot;
let style = document.createElement( 'style' );
style.innerHTML = '#castMetadataImage { background-image: none !important; }';
shadowRootElement.appendChild( style )
Run this right after the player has been initizied and it should fix the issue.
Please share your code. It's difficult to know without any code to review. Did you follow the official guide on https://developers.google.com/cast/docs/caf_receiver/customize_ui for receivers applications? Also you need to check your sender application.
The issue seems to be related to the cssText property - removing this, fixes the rendering issue:
var fixDoubleLogoBug = function(){
try {
document.querySelector("#player")
.shadowRoot
.querySelector("#castMetadataImage").style.cssText = "";
}catch(e){
console.warn("Could not remove logo");
}
}
What i am trying to accomplish is to have a user click on the canvas and the sprite(player) will move to that location and STOP once it reaches that location.
Currently i have the player can click and it will continue in that path which is the default function.
update: function() {
this.player.rotation = this.game.physics.arcade.angleToPointer(this.player);
if (this.game.input.activePointer.justPressed()) {
// move on the direction of input
this.game.physics.arcade.moveToPointer(this.player, this.playerSpeed);
}
}
Maybe its simpler than i think but i cant seem to find a solution.
point in the right direction would be useful :)
I think you look for something like this:
Using Tweens (something very interesting about Phaser)
OR
Using
Arcade Physics (which is an example similar to yours)
So, Brad Larson is awesome. I'm using his GPUImage library since he optimized the CGContextCreateImage for video output to instead render straight into OpenGL. Then he rewrote it to be even more amazing, and half the questions are outdated. The other half have the new callbacks, Like this question, but for the life of me, I can't get the video frames callback to not be nil. (the CMSampleBuffer to CIImage functions)
I know I have to "tag the next frame" to be kept in memory, thanks to his blog. I also know I process it (but GPUImageVideo also does that), then I grab from the framebuffer. Still nill.
The capture command that's supposed to auto-filter it into a CGImage, from the CGImagePicture's processImageUpToFilter function seems to be what I want, and I've seen it mentioned, but I am lost as to how to hook up the output to its frameBuffer.
Or should I use GPUImageRawDataOutput, and how to hook up? I've been copying and pasting, editing, experimenting, but unsure if it's just the fact I don't know openGL enough to hook up the right stuff or?
Any help is appreciated. I wouldn't ask, since so many related questions are up here, but I use them and still get nil on the output.
Here is my current try:
func willOutputSampleBuffer(sampleBuffer: CMSampleBuffer!) {
gpuImageVideoCamera.useNextFrameForImageCapture()
//Next line seems like a waste, as this func is called in GPUImageVideoCamera already.
gpuImageVideoCamera.processVideoSampleBuffer(sampleBuffer);
if let image = gpuImageVideoCamera.imageFromCurrentFramebuffer()
{
//it's nil
}
}
It seems to use the filter instead, and useNextFrame should be AFTER processing to not go super-slow.
Inside of willOutputSampleBuffer, this is it.
if let image = transformFilter.imageFromCurrentFramebuffer()
{
// image not nil now.
}
transformFilter.useNextFrameForImageCapture(); //enusre this comes after
This has given us stunning speeds that beat Google's p2p library. Brad, thanks, everyone should support your efforts.
So I have two PNG images, both non-transparent 24bpp.
One image contains a rainbow, other one contains a single line of text:
I do the same thing with both of them:
var gm = require('gm').subClass({imageMagick: true})
gm("./sources/source.png").bitdepth(24).write("test.png", function(){
console.log("test.png")
});
gm("./sources/source2.png").bitdepth(24).write("test2.png", function(){
console.log("test2.png")
});
where gm is this
And I set both to 24bpp explicitly
In result I have two images with different bit depth:
In some cases I also had 32bpp image.
How can I make it create only 24bpp image (discard alpha channel if needed).
Also, I don't want to create jpgs.
Thanks to #mark-setchell, I could force bit depth. I did it this way in Node:
gm("./sources/source.png")
.out("-define")
.out("png:color-type=2")
.write("test.png", function(){
console.log("test.png")
});
out() is an undocumented method but it basically helps you add custom parameters to commandline. Notice that
.out("-define png:color-type=2")
won't work, it only works if you pass each parameter in individual .out() call
.bitdepth(24) doesn't seem to affect output at all, probably because I did .subClass({imageMagick: true}) above.
My suggestion is to try using -define to set the variable png:color-type=2. As you worked out, and kindly shared with the community, it is done as follows:
gm("./sources/source.png")
.out("-define")
.out("png:color-type=2")
.write("test.png", function(){
console.log("test.png")
});
I used the card layout to switch between two created panels:
var config = {
layout: 'card',
region : 'center',
activeItem: 0,
defaults : {
//height : 160
},
items : [this.ePanel, this.dPanel]
};
Ext.apply(this, config);
The switching takes place based on criteria:
if(params.exchange==='ABCD'){
l.setActiveItem(this.ePanel.id);
} else {
l.setActiveItem(this.dPanel.id);
}
As I switch between panels one of the panel contents get distorted. Are there any solutions to the problem? I am using ExtJS 2.2.
I've never used Ext2, but I've encountered similar difficulties with Ext3. Here are two ideas you can try...
Setting deferredRender to true.
Calling doLayout after setActiveItem, possibly after a small delay (because rendering is often deferred in Ext):
l.setActiveItem(this.ePanel.id);
setTimeout(function() {
l.doLayout();
}, 100); // more may be needed, one need to inspect Ext's code to know the precise value
doLayout is often the solution to layout issues, but it also generally requires a serious amount of debugging in order to have it applied. In effect, layouts are cached (at least in Ext3), so your call can be ignored if Ext consider internally that nothing has changed. Furthermore, as I've already said, rendering is often deferred, so if you don't delay it enough, your doLayout call may be executed before the child elements have been rendered...