Drawing to NSView within NSMenuItem is darkened - draw

I am drawing a coloured circle within an NSView that is contained in an NSMenuItem. When I do so, the circle is drawn in a darker colour to the one I specify and when I add a subview with no drawing code, the area occupied by that view is drawn in the true colour, as illustrated by the image. Could someone explain to me why this is happening and how to fix it?
Many Thanks, Ben.

Related

libGDX - Delete/Subtract regions of a texture from SpriteBatch?

I have a number of square regions in my game screen which, when actors move across these regions, I want the background image to show through from behind.
So, is it possible to draw to a SpriteBatch such that a region is subtracted/deleted from the texture (effectively "punching a hole" in it)?
I can't think how else to achieve this... Scissors seem incredibly impractical for my purpose, as I want to clip the areas INSIDE a number of squares. This is the inverse of Scissors - which clip areas OUTSIDE the scissors' bounds. The thought of calculating dozens of Scissor regions to fill the inverse areas between an assortment of square regions seems too impractical to be the solution... especially if the regions are moving.
Any help or suggestions appreciated!
UPDATE: Image attached.
I want the background to always be visible in the areas marked with the dotted lines. The dotted areas will move, so I'd rather not create more sprites from the background to lay on top, but rather have parts of the actors intersecting the dotted squares not be drawn. (Or any method that will achieve the same effect.)
I think the best hack is to not try and be so precise about clipping your actors, but to just re-draw the background on top the actors (and to clip that).
Specifically:
draw the whole background
draw your actors/sprites
draw the background with one cliprect for one part that "shows through"
draw the background with another cliprect for the other part that "shows through"
draw the dotted boxes around your cliprect areas
Great image, by the way. Easily worth 1000 words. :)

Coloring shapes in winRT?

My objective is to color a rectangle shape in winRT.When the brush leaves rectangle border the coloring should stop.So after coloring I need a fill colored rectangle.
Any help will be really appreciated.
Thanks in advance.
You can use the Clip property to clip any element to a rectangle shape. Note though that right now it only support rectangle clips and for more you would need to use Direct2D or process all the pixels yourself.

HTML5 canvas drawing line over ruler

Please visit the following jsfiddle:- http://jsfiddle.net/mayanknimje87/GfaZ2/3/
there is a ruler and pencil. I can draw line over ruler when it is straight. But when i rotate the scale, drawing of line won't work. Also, i want to give animation, when user put pencil over the ruler (restrict to upper portion of ruler only not to bottom or middle),It start drawing line and animate. Ex. If user put pencil on ruler mark 15 then it should animate and draw line from 15 to 0 . Also user can draw line when pencil touches the top of ruler not in middle and bottom. Please help me out. It will be great to learn. Thanks in advance.
In order for the canvas pixels to be drawn above those image elements, you will have to put the canvas on top. However, the canvas will then soak up the mouse events.
Still, I think you should do that, and then catch the mouse events in the canvas and handle the dragging there.

AS3 move image as the mouse moves

This probably will be very easy for some, but I am stuck on this. I have a map in a movieclip(mc_map) on stage and a small square which acts as a mask to the really bigger size of the same map. What I am want to do is that when I move the mouse on the mc_map(eg: say my cursor is on New York), the small sqaure window will unhide the same area, or will move that bigger image such that the same area is shown under the square mask. I also want to add another cursor(or crosshair) to the stage which is live only in the area of the square and replicates the position of mouse on map. Any help on this will be great thanks.
There are a lot of tutorials on this type of "magnify" effect. See if this one helps: http://www.flashuser.net/flash-actionscript-as3/create-a-magnifying-glass-in-actionscript-3-0.html

Cutting shape out image to show underlying image

I have two images, a gameboard and the same gameboard with all posible player positions in a pressed state. When a player moves to a position on the board, I put the board image over the pressed board image and slice using context.drawImage() on the pressed image, to display the pressed position through the slice. However, my game board contains positions which are not rectangular but different shapes.
Is it possible with html 5 canvas, to cut a non-rectangular shape out of an image to display the underlying image?
I found it's possible to use clip() on shapes but I can't find a similar option on images.
you can create a third image that is a mask with transparent (alpha-channel) pixels and non-transparent pixels, and use a
globalCompositeOperation
to merge the mask and the to-be-masked image into a new image ( think you can use an xor or source-out here..