Re: Drawing over a transparent background
Re: Drawing over a transparent background
- Subject: Re: Drawing over a transparent background
- From: Ron Fleckner <email@hidden>
- Date: Tue, 25 Aug 2009 08:36:23 +1000
On 25/08/2009, at 6:21 AM, Steve Christensen wrote:
On Aug 23, 2009, at 10:00 PM, Ron Fleckner wrote:
On 24/08/2009, at 2:29 PM, Rob Keniger wrote:
On 24/08/2009, at 9:33 AM, Ron Fleckner wrote:
My borderless window has a semi-transparent background. When the
drawing in a subview changes, the background retains a ghost of
the original drawing in the subview. I don't want that ghost
image!
What are you returning for the -isOpaque method of your custom
view? If your view has any parts that have an alpha less than 1.0
then you must return NO from this method.
On 24/08/2009, at 2:36 PM, Kyle Sluder wrote:
On Aug 23, 2009, at 4:33 PM, Ron Fleckner <email@hidden
> wrote:
My borderless window has a semi-transparent background. When the
drawing in a subview changes, the background retains a ghost of
the original drawing in the subview. I don't want that ghost
image!
Have you remembered to override -isOpaque to return NO?
Yes, I return NO. There are four views, each one a subview (built
in IB) of the one below. The background is the content view of the
window with hourHand as a subview, which has minuteHand as a
subview, which has secondHand as a subview. To draw, a timer
callback tells the bottom view to setNeedsDisplay:YES every
second. Each 'hand' view then rotates by the correct amount and
draws it's hand.
1. Are you erasing the view before redrawing the hand?
2. Is there any reason why you couldn't be drawing the entire clock
(face + hands) in a single view? If it's only being updated once a
second, it'll still take considerably less than a second to draw it
all unless you're doing something horribly complicated.
steve
Hi Steve,
I think you are right to suggest drawing it all in one view. That
would probably avoid the problem. The reason I don't is I'm too much
of a maths dolt to be able to work out the point co-ordinates for each
of the hand positions. By giving each hand it's own view, I simply
draw the hand from the centre to the top of the view, and then rotate
the view by the required amount. Of course, each hand needs to be
rotated by a different amount, so having three different views gives
me three different graphics contexts to have three different rotations.
But now while writing this, I realize it's possible to rotate each
hand by using CGContextAddArc(...) and have a different arc for each
hand.
So, that was a very good suggestion. It will take me some time to
implement it and I'm hopeful that it will work.
Thanks very much.
Ron
PS. I was able to work around the ghosting problem, but it involves
having the central hub/target drawing in it's own view on top of the
stack and erasing drawing at the beginning of it's -drawRect:
Curiously, this doesn't erase the hub itself, but all the views
beneath get wiped. As this occurs only during window resizing, you
get a queer floating target graphic by itself until the window stops
resizing.
PPS. By erasing the drawing, I'm assuming you mean fill the rect with
clearColor? That's what I'm doing.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden