Selecting part of circle - image

Before, there is image:
I am totally new in Titanim(Appcelerator). There is task: I must draw or import and select the definite regions of circle. When clicked, it must change colour. Your help will be appreciated.
With regards

Plz Keep two images one with new background and one with original background.Just change the image path and you would be good to go.Something like this
Ti.UI.backgroundColor = 'white';
var win = Ti.UI.createWindow();
var image = Ti.UI.createImageView({
image:'/images/myimage.png'
});
image.addEventListener('click',function(e){
image.image="images/newimage";
});
win.add(image);
win.open();

Related

How can I generate two random colors on opposite sides of the color wheel?

var button = document.querySelectorAll('button');
var drumCount = button.length;
button.addEventListener('click', function(){
this.style.color = '#'+Math.floor(Math.random()*16777215).toString(16));
this.style.backgroundColor = '#'+Math.floor(Math.random()*16777215).toString(16)
});
I have code that creates a random color, but I am wondering how to generate two random colors on the opposite side of the color wheel.
I know it seems trivial, but I have been at it for a while now, trying to figure this out. Any help is greatly appreciated

Put an image in the center of a cell with migradoc

I need to put an image in the center of a table's cell.
When I add the image in a cell the image is aligned topleft.
How can I align the image in the center of a cell?
You might need to add a paragraph to the cell, set the alignment on the paragraph, and then add the image to the paragraph.
row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
row.Cells[0].AddParagraph().AddImage(imageLocation);
row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
In my version of MigraDoc, Jeff and Reuben's solution does not work as shown: Setting the cell's Format.Alignment property has no effect, even when the image is inside a paragraph.
However, what does work for me is to put the image in a paragraph, just as Jeff and Reuben say, then give the paragraph a named style which includes centering.
In my method which predefines all my styles, I do something like:
// Here we assume the "TableText" style has already been created
var sty = doc.Styles.AddStyle( "TableTextCenter", "TableText" );
sty.ParagraphFormat.Alignment = ParagraphAlignment.Center;
And at the point where I add the image, I do this:
var para = table.Cells[ 0 ].AddParagraph();
para.Style = "TableTextCenter"; // <----- This is the magic!
var img = para.AddImage( imageFileSpec );
img.LockAspectRatio = true;
img.Width = "4cm";
img.WrapFormat = new WrapFormat {
Style = WrapStyle.Through
};
As #Reuben says, what is interesting is:
row.Cells[0].AddParagraph().AddImage(imageLocation);
I was trying with
row.Cells[0].AddImage(imageLocation);
And the image was inserted in the document but I couln't get it centered.

How to add a background picture to a Jit infovis spacetree

I need to add a picture to a spacetree to serve as a background to a spacetree.
I have tried several ways but succeeded at none, mainly for the following 2 reasons:
- positioning on the canvas (coordinates 0,0 do not seem to be the correct positioning. it is in the minus!)
- each time the spacetree redraws, it clear the canvas.
Any help will be sincerely appreciated.
guys, what I did is straight forward: if you use the example from the infovis spacetree,
please add the following right after :
st.compute();
//optional: make a translation of the tree
st.geom.translate(new $jit.Complex(-200, 0), "current");
//what I added
//where myimage is an image I load in the DOM normally.
var ctx = st.canvas.getCtx();
var imageObj = document.getElementById("myimage");
ctx.drawImage(imageObj, -700, -500);

kineticjs stage.getAbsoluteMousePosition()?

I am playing with kineticjs with a draggable and zoomable stage and I'd like to know if there is a way to get the stage.getAbsoluteMousePosition() as we can have the absolutePosition of a Node.
Here is the jsfiddle showing a use case, note the position of the tooltip when you zoom in/out.
The interesting part is here:
circle.on('mouseover mousemove',function(){
var mousePos = stage.getMousePosition();
tooltip.setPosition(mousePos.x-stage.getAbsolutePosition().x,mousePos.y-stage.getAbsolutePosition().y);
tooltip.setVisible(true);
tooltip.moveToTop();
layer.draw();
});
I am having trouble to make it work and I believe with the getAbsoluteMousePosition would fix it.
Best,
Edit: This question is outdated.
Outdated Answer
Ok, fixed it myself even thought I don't use the absoluteposition I wanted to.
Here is the jsfiddle, the proper way of doing it was like this:
circle.on('mouseover mousemove', function () {
var mousePos = stage.getMousePosition();
tooltip.setPosition(mousePos.x/ui.scale-stage.getAbsolutePosition().x/ui.scale+stage.getOffset().x,
mousePos.y/ui.scale-stage.getAbsolutePosition().y/ui.scale+stage.getOffset().y);
tooltip.setVisible(true);
tooltip.moveToTop();
layer.draw();
});
If I understand correctly, if you want to get the absolute position of your mouse pointer to the screen this is how you could do it:
circle.on('mouseover mousemove', function (e) {
var mousePos = stage.getMousePosition();
var absoluteX = e.screenX;
var absoluteY = e.screenY;
tooltip.setPosition(mousePos.x - absoluteX, mousePos.y - absoluteY);
tooltip.setVisible(true);
tooltip.moveToTop();
layer.draw();
});
This doesn't solve your answer though as the (x,y) coordinate of the mouse should be relative to the canvas, not your screen. I'm not exactly sure why tooltip.setPosition(mousePos.x, mousePos.y); wouldn't work, the zoom must be messing up the mousePos coordinates relatively somehow.
Anyways, if you only need the tooltip to hover above the correct node, and not follow the mouse position, than this should work for you:
tooltip.setPosition(this.getX(), this.getY());
And if you need, you could offset it by a certain amount for example half the height (radius).
tooltip.setPosition(this.getX(), this.getY()-this.getHeight()/2);
http://jsfiddle.net/projeqht/nDpYr/

Wp7 clear canvas value

I am using canvas to add image programatically.
for example:
Image image1=new image1();
Image image2=new image1();
var left = new BitmapImage();
left.UriSource = new Uri("images/box.png", UriKind.Relative);
image1.Source = left;
image2.Source = left;
ContentPanelCanvas.Children.Add(image1);
ContentPanelCanvas.Children.Add(image2);
First time enter the loop Add Image to canvas. second time i want to clear canvas.
and again add different images same canvas.
Is this possible wp7.
tell some idea to do this.
thanks
Yes, it is possible:
ContentPanelCanvas.Children.Clear();
This will empty the canvas.
Why not simply change the Source property of the images you already added?

Resources