How can we change the opacity of image on 2Drender? - xtk

I would to know if there is a function that change the opasity of image on 2D render (like the action of hover on the canvas)
thanks a lot,AMAL

2D render is basic a HTML canvas, opacity can be done by settings globalAlpha property :
ctx.globalAlpha=0.2;

Look at the following line of code in renderer2D:
var _labelOpacity = 1;//_volume._labelmap._opacity;
(https://github.com/xtk/X/blob/master/visualization/renderer2D.js#L1277)
I don't know the reason the opacity was changed to be always 1, but I uncommented the right side and it worked for me.

Related

Changing tick label colour in mpld3

I am trying to plot stuff using matplotlib and mpld3. This is the code I use to generate my graph:
_fig = plt.figure()
_pl = _fig.add_subplot(111)
_pl.plot(_times, _values)
_pl.set_xlabel("Time")
_pl.set_ylabel("Value")
_pl.tick_params(direction="out", axis="both", colors="white", which="both")
_pl.xaxis.label.set_color("white")
_pl.yaxis.label.set_color("white")
_data = mpld3.fig_to_html(_fig)
.... send to client to be rendered
A graph is created and all the dynamic controls work. "Time" and "Value" labels get printed in white but tick labels in black.
If I skip mpld3 and test it with plt.show(), all tick labels get printed in white. When I check the javascript code generated by mpld3, I do not seem to detect the colour setting there for tick labels.
If I use another parameter, like font size, in tick_params it does have an effect. Only the colour gets ignored, which causes the labels to be printed in black on a dark blue background.
How do I change this?
Edit:
When inspecting the actual page rendered, there seems to be a "fill" property that determines the colour.
div#fig_el249691400950908834083380374260 .mpld3-xaxis text
{font-family:sans-serif; font-size:10px; fill:black; stroke:none; }
I tried overriding this in css but I could not figure out how to do it. This seems to override whatever I set elsewhere. It appears mpld3 sets the colour of the tick label, but how do I modify this?
Hannu
mpld3 only supports a subset of matplotlib's full capabilities, and tick formatting is one of the many things that is not yet supported. There is a partial list of these missing features on the mpld3 wiki.

Is it possible to draw on an SFML window regardless of views?

I have a game I'm currently working on, and it uses multiple views (for a minimap for example).
Thing is, I would like to have a fading effect added at some point, so I thought I'd create a black image that is the size of the screen and change its alpha value with a timer. That part is not a problem.
What happens right now is the main area (ie window default view) is fading (because the opacity of the image is increasing), but the minimap (minimap view) is unaffected. This is normal behaviour for views, but is there a way to draw an image to the whole window, regardless of the views ?
Thanks in advance
To clarify, you have the default view where you'll draw the main game, then you'll have the minimap view where you would draw the minimap. At some point in the game you want the whole screen to fade to black. It sounds like you've been trying to draw a black image on the default view (changing the alpha) to make this effect work.
So, you need a third view that you draw your black image on to get this fading effect.

Qt GraphicsItem transformation affects all items in scene

I have this embedded Qt application that uses the QGraphics framework to display a web view.
The dimensions of the web view are 1280*720 pixels, and the QGraphicsView is set to render the scene at these coordinates (0,0, 1280x720).
I'm trying to add a loading indicator on the top right corner (at 1100,50), which is a simple PNG image that I rotate every now and then using a QTimeLine.
Code looks like this (I found the transformation trick on the internet):
// loading_indic initialization:
QGraphicsPixmapItem *loading_indic =
new QGraphicsPixmapItem( QPixmap("./resources/loading_64.png") );
loading_indic->setPos(QPoint(1100.0,50.0));
QTimeLine timeline = new QTimeLine(1000);
timeline->setFrameRange(0,steps);
connect(timeline, SIGNAL(valueChanged(qreal)), this, SLOT(updateStep(qreal)));
timeline->start();
// called at each step of a QTimeLine:
void updateStep(qreal step) {
QTransform transformation = QTransform()
// place coordinate system to the center of the image
.translate( width/2.0, height/2.0)
// rotate the image in this new coordinate system
.rotate(new_angle)
// replace the coordinate system to the original
.translate( -width/2.0, -height/2.0);
loading_indic->setTransform(transformation);
}
Now, my problem is that when doing this, it looks like the WebView is translated as well, resulting in everything being displayed in the center of the screen.
Result looks like this:
The webview is supposed to fill the screen, and the loading indicator should be on top right...
My scene contains only two items:
Scene
|
\____ QGraphicsWebView
\____ QGraphicsPixmapItem // loading indicator
What am I doing wrong here?
Solved my problem..
I don't know why, but it looks like adding this PNG item to the scene was screwing up with the scene's rectangle.
Doing this:
_scene.addItem(loading_indic);
loading_indic->setPos(1100.0, 50.0);
_scene.setSceneRect(0.0,0.0,1280.0,720.0); // resets the scene's rectangle ?!
loading_indic->startAnimation();
solved the problem. Now my items are correctly placed on screen.
If somebody has an explanation to this, I'll gladly accept his answer.

How to remove black screen between scenes in CCTransitionPageTurn?

I need to use CCTransitionPageTurn in my app between scenes.
When i run this transition, my running scene looks nice - it turns like page.
but at the background i see black screen(during page turn animation), that is replaced later by new scene.
And i want to see new scene in the background(during animation), when i start this transition.
Can anybody help me?
Oh, i found out the answer.
All works as it should, after i commented out this line
//director.projection = kCCDirectorProjection2D;
also i turned on depth buffer and changed depthformat.

gradients using only html and css and javascript?

Is there a way to do gradients in css/html/javascript only that will work across all the major browsers? (MS IE 5+, Firefox, Opera, Safari)?
Edit: I would like to do this for backgrounds (header, main panel, side panels). Also, would like to have vertical line gradients as well.
Edit: after reading the responses, let's open this up to Javascript solutions as well, since HTML/CSS by itself makes it tougher to achieve.
I've done this before as a gimmick, using javascript like:
var parent = document.getElementByID('foo');
for(var i=0; i< count; i++) {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.width='100%';
div.style.height = 1/count+"%";
div.style.top = i/count+"%";
div.style.zIndex = -1;
parent.appendChild(div);
}
If your requirement is just to have a gradient, you really should use a gradient image set as background-image in css. In my case, I was animating the colors and position of the gradient as well. I can't vouch for now cross-browser it is (for starters, make sure the parent has some position applied, otherwise it won't be a position-container for the absolute positioning.
I'm unclear on the implementation details you are seeking (such as background, or just a border along the side of the window, etc); however, it's possible albeit a little tedious.
One example that comes to mind would be to have n-block level elements, such as divs, and then give them each a small height (a couple of pixels, for example) and then gradually change the background color of each subsequent element.
I use the gradient CSS code generator by colorzilla: http://www.colorzilla.com/gradient-editor/
It has polyfills for IE - but not sure how far back it goes.
I think the short answer is no.
You can create something that looks like a gradient using only css, but to then use it like an image background... I think that is pushing it a bit.
EDIT (feeling silly)
I found the solution: http://en.wikipedia.org/wiki/JPEG
There are lots of ways to create a gradient now.
1. You can create image for it.
2. Use CSS3 Gradient, it can be linear, radial and repeating.
Syntax for linear :
linear-gradient: ([angle | to ] ,[ [color-stop], [color-stop]+);
Syntax for radial :
linear-gradient: ([angle | to ] ,[ [color-stop], [color-stop]+);
For IE6 to IE 9 we can use the filter property or you can also use CSS3Pie.
Following are some referances that will help:
Mozilla MDN
CSS3File