Finding color on flex page - apache-flex

I want to find some color on flex page exists or not?
For example
if(red color exists on page){
Alert.show("red exixts");
}else{
Alert.show("red does not exists");
}
so before writing this if else block,i need to find the red color(any where on flex page)
Note:- My page do not hav any images.with images i m getting the color.My page has a canvas and hboxes and diff texts with diff colors.
Done with bitmap,bitmap data.....NO LUCK :( Please help me wit this

Draw your page (application?) into bitmap. Then analyze each pixel (may take time). What red do you need? If you accept not only pure red (0xFF0000), define minimum level for red channel and maximum for other channels. As soon as "red" pixel is found, quit checking.

I would suggest that you start iterating over all the children objects of the application, get the colour property, using getStyle("propertyname"), and you will find the colour of all possible objects.This is much better than rendering the whole app, into a bitmap and then testing for each pixel.

Related

Zoom & crop an image and draw an svg-square on top (in angular)

"A stackblitz is worth a thousand words": https://stackblitz.com/edit/angular-zoom-crop-marker
Basically what I'm trying to do is to have a square drawn above a certain position in an image (<img>), and have that dynamically adjust to the image while being zoomed in / out and cropped. The stackblitz link has 3 views, the basic view which is a plain image, a zoomable view (which I got working as well) and a view where the imaged is "zoomed in and cropped" while being zoomable - This is where I need your help.
Should I crop using object-fit in some way? Is it better if I use a canvas to handle this? I've been at this for a whole day I and I feel my css knowledge is too limited to pull this of.
Bonus question: How would I go about to have the zoom-in zoom-out buttons add/remove one image per row using only css flex-box? (ie: not statically adding x pixles in height and width, but rather increase or decrease the size of each image so that another image is removed or added (per row) while always filling up all the available space)
Thank you in advance!
Managed to solve it myself. stackblitz updated with a working solution.

Collision with fixed pixel-size items on QGraphicsView

I'm using Qt's GraphicsView/GraphicsScene framework, and I have to draw some line items.
To be sure these items are always visible (independant of the zoom level) I use a cosmetic pen, with a size of 3 (for example) so I always get lines of 3 pixels width drawn on screen.
But these items doesn't receive mouse events (such as hoverEnterEvent/hoverLeaveEvent) when I'm zooming out a lot.
I've digged in the code, and it appears that all collisions tests are done with the return value of the shape() function.
So I've tried to re-implement "shape()" and also "contains()" and "collidesWithPath()" methods, but I still have problems to detect collisions (because when zoom is changed, I need to re-update the shape for example).
Is there any tricks to do that ?
In an efficient way ? (without re-updating the item's shape at every zoom change)
Thanks

Flex Change image color dynamically?

I have a image declared like the following:
[Bindable]
[Embed( source="assets/banana.png" )]
public var iconBANANA : Class;
It is involving into itemRenderer, but I wish to change the color of the image when some event occurs (like clicking above or something).
The rest of the objects used the image shall remain unchanged, only the object on which the event has occurred shall change the color of the image.
But the biggest question is :
How to change the image color mainly - like there is a Blue area on image - to turn it on Green, or Yellow ?
I believe what you're looking for are Filters. What you're explaning (changing one color to another) is not exactly trivial and going into some fairly complex image manipulation but you can get some results using the ColorMatrixFilter.
You're looking for beginBitmapFill.

Prevent overlapping DragDrop Images in Flex

I am trying to create basically a puzzle in Flex Builder 3. I display images from an array onto a canvas that can be dragged and dropped around the canvas. My problem is that I don't want the images to be able to overlap each other. Any ideas on how to prevent this??
They can overlap as you drag but not when dropped, they need to "snap" to the nearest point that is not already occupied by another image.
I did something similar to this. What you do is onDrop add the target (x,x + object.width) and (y,y + object.height) to an array. Prior to this, if array is not null, check to see if your new object's x or y value is within an existing range in the array. If so, do not allow drop else allow the drop. All images, regardless of "picture" are square/rectangles so this would prevent the overlapping. However, if you have complex pictures (i.e. circles/hexagons) and are trying to butt the edges together, then this method will not work.

Any advice on 'breaking' an object out of its layout in Flex - for animation purposes?

If I have an object in a layout in Flex what is a good way to 'break it out' of that layout to be able to animate it.
For instance I have an image and a caption arranged at an angle. I want to make the image 'zoom out' slightly when the mouse rolls over it. Since its in a layout container is active if I were to resize it then obviously it would move around everything else.
I dont think I can achieve what I want by just setting includeinlayout=false.
Any experience with best practices on this?
My best idea I'm wondering about is making the image invisible and creating another image at the same location by using the screen coordinate conversion functions. This jsut semes clumsy
Wrap your object in a fixed size Canvas so that the layout upstream will remain the same. Then position the object manually within that container and then set its includeInLayout to false. At that point, you could do whatever you wanted with the interior object. Oh, also set clipContent to false. This should work whether you want it to grow or shrink.
If this is an itemrenderer or something that you've wrapped into a class, you could handle all of this in the class definition and make it transparent to consumers of the object. You'd also be able to write a mouseOver function that did what you wanted with the interior object that should zoom.

Resources