I can't create a GCKUICastButton to add to my navigationBar, I got this error:
GCKUICastButton.m:340: -[GCKUICastButton initializeDefaultAccessibilityLabels] - Localized string initialization failed.
when I ask for a GCKUICastButton:
let castButton = GCKUICastButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24))
castButton.tintColor = .white
let castButtonBarItem = UIBarButtonItem(customView: castButton)
I got an uninitialized cast button.
There was a bug on my pod installation, was missing GoogleCastCoreResources and GoogleCastUIRessource Bundles
Related
I'm trying to compose a ton of images (2300) into a transparent png using sharp. I'm trying that with the following code:
await sharp({
create: {
width: 256,
height: 256,
channels: 4,
background: { r: 0, g: 0, b: 0, alpha: 0 },
},
})
.composite(images)
.png()
.toBuffer();
Where images is an array generated like this:
const pinSvg = fs.readFileSync("./icon_web_pin_record_basic.svg");
const pinWidth = 18;
const pinHeight = 25;
const generateImageFromLocationArray = (locations) => {
const images = [];
for (let i = 0; i < locations.length; i++) {
const [x, y] = locations[i];
images.push({
input: pinSvg,
blend: "add",
left: x - Math.floor(pinWidth / 2),
top: y - pinHeight,
});
}
return images;
};
With a few images, everything works fine, but with 2300 images, I get the following error:
[1] 12202 bus error node index.js
I have tried to set sharp.cache(false), but that has not worked. Any idea how to solve it? I suppose I'm getting some overflow, but I do not know how to fix it.
I have a PIXI.Graphics object where I add 9 times a 16x16 texture, then I upscale, but the result is very blurry.
Code :
const graphics: PIXI.Graphics = new PIXI.Graphics();
const slotTexture: PIXI.Texture = game.textureManager.getTexture('hotBarSlot');
graphics.beginTextureFill({
texture: slotTexture,
});
graphics.drawRect(0, 0, width * 16, height * 16);
graphics.endFill();
graphics.scale.set(6, 6);
There is the result I get :
This is my texture (it's really small) :
How can I fix this problem ?
Okay, I figure it out!
I have to add this line :
slotTexture.texture.baseTexture.scaleMode = PIXI.SCALE_MODES.NEAREST;
I would like to render a live wallpaper into the X root window. This is currently not possible directly through the API glutin exposes.
I found a post where the asker seems to eventually figure it out: How can I make a window override-redirect with glutin?.
However, it seems that the code snippet from the answer is not enough to achieve the desired effect: once the flag is set, the previously-created window disappears, but nothing is rendered to the root window. What am I missing?
Here's what I have so far:
let mut events_loop = glium::glutin::EventsLoop::new();
let context = glium::glutin::ContextBuilder::new();
let window = glium::glutin::WindowBuilder::new()
.with_dimensions(800, 600)
.with_title("TEST");
let display = glium::Display::new(window, context, &events_loop).unwrap();
unsafe {
use glium::glutin::os::unix::WindowExt;
use winit::os::unix::x11::XConnection;
use winit::os::unix::x11::ffi::{Display, XID, CWOverrideRedirect, XSetWindowAttributes};
let x_connection = std::sync::Arc::<XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap());
let x_display = display.gl_window().get_xlib_display().unwrap() as *mut Display;
let x_window = display.gl_window().get_xlib_window().unwrap() as XID;
((*x_connection).xlib.XChangeWindowAttributes)(
x_display,
x_window,
CWOverrideRedirect,
&mut XSetWindowAttributes {
background_pixmap: 0,
background_pixel: 0,
border_pixmap: 0,
border_pixel: 0,
bit_gravity: 0,
win_gravity: 0,
backing_store: 0,
backing_planes: 0,
backing_pixel: 0,
save_under: 0,
event_mask: 0,
do_not_propagate_mask: 0,
override_redirect: 1,
colormap: 0,
cursor: 0,
}
);
((*x_connection).xlib.XUnmapWindow)(x_display, x_window);
((*x_connection).xlib.XMapWindow)(x_display, x_window);
}
I'm creating a program that uses glutin, and I want to provide a command-line flag to make the window override-redirect so it can be used as a desktop wallpaper for certain window managers that don't support the desktop window type.
I've done a lot of research and managed to cobble together a block of code that I thought would work, using the provided xlib display and window from glutin. Here is my existing code:
unsafe {
use glutin::os::unix::WindowExt;
let x_connection = std::sync::Arc::<glutin::os::unix::x11::XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap());
((*x_connection).xlib.XChangeWindowAttributes)(
display.gl_window().get_xlib_display().unwrap() as *mut glutin::os::unix::x11::ffi::Display,
display.gl_window().get_xlib_window().unwrap() as glutin::os::unix::x11::ffi::XID,
glutin::os::unix::x11::ffi::CWOverrideRedirect,
&mut glutin::os::unix::x11::ffi::XSetWindowAttributes {
background_pixmap: 0,
background_pixel: 0,
border_pixmap: 0,
border_pixel: 0,
bit_gravity: 0,
win_gravity: 0,
backing_store: 0,
backing_planes: 0,
backing_pixel: 0,
save_under: 0,
event_mask: 0,
do_not_propagate_mask: 0,
override_redirect: 1,
colormap: 0,
cursor: 0,
}
);
}
It doesn't give me any errors, and compiles and runs fine with the rest of the code, but it doesn't make the window override-redirect like I want to.
I figured it out. The override-redirect only takes place when the window is mapped, so if I unmap it and map it again then it works!
Here is the code now:
unsafe {
use glutin::os::unix::WindowExt;
use glutin::os::unix::x11::XConnection;
use glutin::os::unix::x11::ffi::{Display, XID, CWOverrideRedirect, XSetWindowAttributes};
let x_connection = std::sync::Arc::<XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap());
let x_display = display.gl_window().get_xlib_display().unwrap() as *mut Display;
let x_window = display.gl_window().get_xlib_window().unwrap() as XID;
((*x_connection).xlib.XChangeWindowAttributes)(
x_display,
x_window,
CWOverrideRedirect,
&mut XSetWindowAttributes {
background_pixmap: 0,
background_pixel: 0,
border_pixmap: 0,
border_pixel: 0,
bit_gravity: 0,
win_gravity: 0,
backing_store: 0,
backing_planes: 0,
backing_pixel: 0,
save_under: 0,
event_mask: 0,
do_not_propagate_mask: 0,
override_redirect: 1,
colormap: 0,
cursor: 0,
}
);
((*x_connection).xlib.XUnmapWindow)(x_display, x_window);
((*x_connection).xlib.XMapWindow)(x_display, x_window);
}
I have google it and I know that properly way to add z-index is by order of creating but I have different situation.
I'm creating card game and I want to move card on click and after that card should be on top which is not possible so I have solved in following way.
In function which is called on card click I'm destroying that card and creating identically new card which is on top because it is created last.
Is there another way of solving this situation?
Thank you
On card release you could use BringToTop (see also moveDown, moveUp and sendToBack methods that can be usefull to you)
Something like:
game.world.bringToTop(activeCard);
After this line, activeCard should be on top of all others sprites or groups.
if the objects/sprites are not in the same group game.world.bringToTop(target) will not work.
a more solid solution is to add objects to groups in the order you want them to be layered like so:
// Groups for drawing layers
var back_layer = game.add.group();
var mid_layer = game.add.group();
var front_layer = game.add.group();
// It doesn't matter what order you add things to these groups, the draw order will be back, mid, front (unless you change it...)
back_layer.create(0, 0, "bg");
front_layer.create(0, 0, "front");
mid_layer.create(300, 200, "object1");
mid_layer.create(500, 400, "object2");
explained here - www.html5gamedevs.com post
Personally I worked with both solutions and the groups one proved to be much more workable as the project starts to scale
hope this helps
You can test ordering with these;
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
game.global = {};
function preload () {
}
function create () {
game.physics.startSystem(Phaser.Physics.ARCADE);
game.stage.backgroundColor = '#01555f';
this.gfx = game.add.graphics(0, 0);
this.gfx.visible = false;
this.gfx.beginFill(0x02C487, 1);
this.gfx.drawRect(100, 100, 250, 1);
this.barSprite = game.add.sprite(100, 500, this.gfx.generateTexture());
this.barSprite.anchor.y = 1;
game.add.tween(this.barSprite).to({ height: 400 }, 1000, Phaser.Easing.Default, true, 0);
var bubbleGfx = game.add.graphics(0, 0);
bubbleGfx.lineStyle(2 * 1, 0x000000, 1);
bubbleGfx.visible = true;
bubbleGfx.beginFill(0xffffff, 1);
bubbleGfx.drawRoundedRect(300, 150, 200, 100, 8);
this.gfx2 = game.add.graphics(0, 0);
this.gfx2.visible = false;
this.gfx2.beginFill(0x02C111, 1);
this.gfx2.drawRect(150, 100, 250, 1);
this.barSprite2 = game.add.sprite(400, 500, this.gfx2.generateTexture());
this.barSprite2.anchor.y = 1;
game.add.tween(this.barSprite2).to({ height: 400 }, 1000, Phaser.Easing.Default, true, 0);
}
function update () {
}