Re: NSAttributedString fill with gradient
Why would you even expect that to work? NSGradient is not a colour. At present there is no supported attribute for gradients. Oh? You might want to let the folks at Apple know that ;) [[NSColor selectedMenuItemColor] set]; NSRectFill(someRect); -matt On Thu, Dec 17, 2009 at 3:50 PM, Graham Cox graham@bigpond.com wrote: On 18/12/2009, at 4:31 AM, Chris Purcell wrote: I've tried setting the gradient as NSForegroundColorAttributeName in the attributes dictionary when creating the string but as I expected that didn't work. How would I go about filling the string with a gradient? Why would you even expect that to work? NSGradient is not a colour. At present there is no supported attribute for gradients. You could create this effect by converting the string to its glyphs as a path and fill the path. Alternatively you can create a subclass of NSLayoutManager and override the method: - (void)showPackedGlyphs:(char *)glyphs length:(NSUInteger)glyphLenglyphRange:(NSRange)glyphRange atPoint:(NSPoint)point font:(NSFont *)font color:(NSColor*)color printingAdjustment:(NSSize)printingAdjustment and render the glyphs using a gradient. Doing that implies you'll need to set up a text system programatically, which is a fairly advanced topic - see: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArchitecture/TextArchitecture.pdf --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: breakout game - openGL or quartz?
Everyone seems to have already pointed you in the right direction, but as someone who has specific experience making such a game solo (http://bravobug.com/megabrickbash3000) I wanted to just throw in my .02 that OpenGL is definitely the way to go. NeHe's tutorials will be very handy along the way and iDevGames is definitely worth visiting, as the folks are generally very helpful and know their stuff, and you can likely get quite a bit of help with all manner of game dev topics (collision, audio, interface, etc.), not just graphics. Be sure to also look into OpenAL for your sound effects. And you may even want to take a peek at a 2D collision/physics library like Chipmunks (http://code.google.com/p/chipmunk-physics/). It's not really necessary for a breakout-type game but you might be surprised at how much work it can save you. And you can do some really cool stuff with it. Cheers~ -Matt On Sun, Dec 6, 2009 at 10:48 PM, Patrick J. Collins patr...@collinatorstudios.com wrote: Hi everyone, I wrote a breakout style game for actionscript3: http://collinatorstudios.com/dev/super_collins_breakout and it's been on my mind to make a version for the iPhone.. But before I do that, I thought it would be good to just make a version for plain old OS X... So before I do this, I wanted to ask the opinions of every one here-- Should I use OpenGL or quartz/core animation for my graphics drawing? I am thinking that I want to use OpenGL-- even though the game is 2D, I still would like to be able to do gradients and shading and glowing, etc.. Which I am assuming isn't going to be as easy to accomplish with quartz/core animation. Also if anyone recommends any particular books or online tutorials for learning how to draw simple rectangles and spheres, and make them glow, etc, that would be great. Thanks! Patrick J. Collins http://collinatorstudios.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Transparency Help 2
Here is a method that applies 'mask' based on a given NSColor. ie, you pass it an NSImage, a NSColor (in your case, white), and a threshold, and it will make transparent all the pixels of that color within a threshold. So you can use this to knock out the white pixels of an NSImage. Then, of course, just draw that new NSImage into your view using NSCompositeSourceOver. (PS: This was thrown together pretty quickly so you may need to tweak it if it doesn't suit your purposes, but you can at the least perhaps use it as a jumping off point) -(NSImage*)calcMaskForColor:(NSColor*)c :(int)threshold :(NSImage*)img { NSBitmapImageRep *imageData = [NSBitmapImageRep imageRepWithData: [img TIFFRepresentation]]; int i=0; int w = [imageData pixelsWide]; int h = [imageData pixelsHigh]; int numPixels = w * h; unsigned char *data = [imageData bitmapData]; unsigned char vals[4]; unsigned char col[3]; //assumes nscolor passed has r/g/b components //ie, dont just pass [NSColor whiteColor] col[0] = [c redComponent]*255; col[1] = [c greenComponent]*255; col[2] = [c blueComponent]*255; int dif; //assumes RGBA for(i=0;i(numPixels*4);i+=4) { memcpy(vals, data+i, 4); //custom alpha check, you can remove or modify: if(vals[3] 240) { //visible pixel, check color dif = 0; dif += abs(vals[0] - col[0]); dif += abs(vals[1] - col[1]); dif += abs(vals[2] - col[2]); if(dif threshold) { memset(data + i, 0, 4); } } } NSImage *newImg = [[[NSImage alloc] initWithSize: NSMakeSize(w,h)] autorelease]; [newImg addRepresentation: imageData]; return newImg; } -matt On Mon, Nov 23, 2009 at 10:01 AM, R T chromaticsp...@yahoo.com wrote: Given: A litho Image, Black White pixels only. I want to show just the Black Pixels in a subclassed NSView. I've posted previously with some code and had 1 simple response that has not panned out for me. Any ideas out there, anybody been down this road? Thanks Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Detecting when sheet has finished appearing
-beginSheet methods return once the sheet has finished animating (IIRC). If you call -beginSheet you can add the code you want to execute after the sheet has been displayed immediately after that (but before any modal calls such as -runModalForWindow). The code will execute after the sheet animation has finished. On Sat, Oct 10, 2009 at 3:50 PM, Squ Aire squ...@live.com wrote: A sheet animates into view. I want to detect it when this animation is complete. There are certain things (like a progressbar) that I wish to start only when the sheet has actually finished appearing on the screen. I don't want the progress bar to start before that. All I can find are a bunch of SheetWillBegin stuff. But I cannot seem to find any SheetDidBegin stuff. I therefore ask: How can I detect it when the sheet has completely appeared on the screen, i.e. detect when the sheet animation is complete? _ Windows Live: Make it easier for your friends to see what you’re up to on Facebook. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092009___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Disappearing NSStatusItem
Make sure you're properly -retain'ing it. Just because you have an ivar pointing to it doesn't mean it will stick around after GC/autorelease pool releases stuff. You'll need to explicitly -retain the NSStatusItem since NSStatusBar does not. On Fri, Sep 25, 2009 at 11:21 AM, Jacob Schwartz jakehschwa...@gmail.com wrote: Hello again, After making headway on my first cocoa app, I have run into an issue. I have created a NSStatusItem in my class called Application.m. When I run, the icon appears in my menubar but then disappears and becomes ineligable to click. I read something somewehere about thr garbage collection taking it away but I have it saved as an instance in my class so Im out of ideas. I also read about the AppDelegate class that is made for me when I make a new project but I don't know how to use that. Fail. Anyway thanks again everyone. -Jake ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: drawing/masking one image with the alpha value from another
Modifying the bitmap data yourself shouldn't be too difficult, for an NSBitmapImageRep you'd just grab the data with the -bitmapData method. But have you checked out CIFilter? I'm not entirely sure I understood what your goal is but there's likely a filter in place already that will do it for you: https://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CoreImageFilterReference/Reference/reference.html https://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/QuartzCoreFramework/Classes/CIFilter_Class/Reference/Reference.html On Mon, Sep 21, 2009 at 9:32 PM, Roland King r...@rols.org wrote: I'm trying to construct an image which is colored according to the alpha value of a different image. I've been hunting around the Quartz Core docs and I can't figure out a good way to do this. The motivation is to do something similar to what apple does on the iphone tabbar items which are drawn white or blue using the alpha of the image you supply and it's a pretty good effect I want to reuse. So for instance if I my drawing color is D and the point on my underlying image is {r,g,b,a}, I want to draw a point of color S * a. Assume that I have the image I want to process and I can get that into a bitmap - because I do and I have. I've looked at all the colour blending modes but unless I've missed something, all of them deal, as you'd expect, in colour, not alpha, so I can't find one of those I think I can use which totally ignores the colour information. I thought about using a CFImageMask which has points which are white where the underlyer is alpha=1 and black where it's 0 and all points between but creating that from the original image is the same problem.. I thought about wandering through the bytes of data in the bitmap (assuming I can even figure out how to access them which currently I cannot) and changing them but that seems pretty hokey even if I deal correctly with the byte orderings the packing and .. getting to the data in the first place. I'm sure I've entirely missed some piece of Quartz or CF here which does exactly what I want, or a blending mode I can use cleverly for this. Any pointers would be very useful. Roland ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Possible reasons why no help is available?
Here's a walkthrough, in case it might be helpful: http://bravobug.com/news/?p=160 On Fri, Aug 21, 2009 at 4:19 PM, Brant Searsbr...@mac.com wrote: Hi. I'm trying to get a Help Book to open for my application. I have a pile of .htm and .css files that were given to me by someone who generated them from Robo Help. I put them in a folder called XX Help, dropped the folder onto Help Indexer which generated a filed called XX Help.helpindex and added it to the folder. I then added step to my build script that copies XX Help to Resources/English.lproj in my app bundle. Then I added a key called CFBundleHelpBookFolder with the name XX Help. Then in my applicationDidFinishLaunching method, I call AHRegisterHelpBook() with the FSRef from my budle. When I call [NSApp showHelp: nil]; in response to the user choosing the help menu item for the app, I get an messagebox that sayd Help isn't available for XX. I made sure there is a reasonable file called index.html in the help book. What should I do to get this to open? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSProgressIndicator Subclass is slow
Have you checked this: http://developer.apple.com/qa/qa2006/qa1473.html If it's a redraw issue that should solve your problem. On Fri, Aug 21, 2009 at 3:50 PM, PCWizpcwiz.supp...@gmail.com wrote: Hi, I have a subclass of NSProgressIndicator I wrote (is attached). I've overriden the incrementBy: and setMaxValue: methods to redraw the progress bar every time its value changes. Then I have a list of shell commands that are run, and after each command the value of the progress bar is incremented by one. The problem is that the progress bar doesn't update after each command, it updates after all the commands have finished. I think this might be a problem with me redrawing the progress bar every time it changes, but I don't know how else to do it Thanks ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/bravobug%40gmail.com This email sent to bravo...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com