Re: [Math] sin(), cos() not working? What special magic must I use to summon their powers?
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:cc:message-id:from:to :in-reply-to:content-type:mime-version:subject:date:references :x-mailer; bh=ggv6zhcdYRkbsitL3tMviuEYM2KzYinTxjZ2jB1hmks=; b=I7q6kX+RfqnRmg2OtL880MRO8rjviNWf3KnVA6riAyfNqnFxPJ1jEvQlIM227WTtTf OF2MjLcK86rSjjgGh0IiLFDkGWGuDCDWqhzzSgqR/Fo9eSJ2FyoQ2lH47m9FmXZdTvYT 5xXYTZA6qd9VeWil/S0cHuRp1Ms3pYOKELR48= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=cc:message-id:from:to:in-reply-to:content-type:mime-version:subject :date:references:x-mailer; b=IF3irJrqbA3VggT5AgCdV5iZzNgMaZWyqrdtzsAbXSmEVo11bpnSQxUEd+NW/5I2Wb atJNeJcyQbOWjuFljBRStUmbW8cS/J1mGYN6x+AB458GOuXzKFVNQsM3FXXQcK7Ew8yj cMlEz2TDqDBZEEKC2yfBF4AMjOPuNcLP+AHCE= The images spat out seem to be quite small, which is a real bonus. Unsurprisingly, I need my hand held again. 2. how do I fill my NSBitmapImageRep with this pretty gradient? Yes, I know it is "in the docs" but they confuse the **** out of me. Thanks for all your help On 1 Oct 2008, at 11:55, Michael Robinson wrote: The CSS could be something like e.g. // Draw here [NSGraphicsContext restoreGraphicsState]; <div class="box"> <div class="tl"></div> <div class="t"></div> <div class="tr"></div> <div class="l"></div> <div class="c"></div> <div class="r"></div> <div class="bl"></div> <div class="b"></div> <div class="br"></div> <div class="content"> <!-- Content here --> </div> </div> +---+---------+---+ |tl | t | tr| +---+---------+---+ | | | | | l | c | r | | | | | +---+---------+---+ |bl | b | br| +---+---------+---+ Yes. Just use e.g. You sir, are a genius. <pastedGraphic.tiff> Potentially, yes. Kind regards, Alastair. -- http://alastairs-place.net _______________________________________________ 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/site_archiver%40lists.apple... Ah, thank you for that. This will allow me to scrap much of my HTML generation code. I need to use CGShading, because a lot of people will be running this on 10.4 (I assume they won't be able to use the other way)? 1. how do I initialize a CGShading object, with my two colours (left right/top bottom) On 1/10/2008, at 11:44 PM, Alastair Houghton wrote: div.box { position: relative } div.box div.tl { position: absolute; top: 0px; left: 0px; z-index: 100 } div.box div.tr { position: absolute; top: 0px; right: 0px; z- index: 100 } div.box div.bl { position: absolute; bottom: 0px; left: 0px; z- index: 100 } div.box div.br { position: absolute; bottom: 0px; left: 0px; z- index: 100 } CSS must be inline, don't see why I can't put this CSS inline, do you? No, there's no reason that this couldn't be done inline. I forgot to add the background image, width and height properties for the tl, tr, bl and br elements, but you get the idea, I'm sure. Likewise, it wouldn't be hard to set up a bitmap in Cocoa and then render a gradient-filled box with rounded corners into it. Nor would this restrict you to a particular final size, since you could just slice it up into pieces in your code before saving the pieces to disk as .png files or whatever. You don't happen to know a good place to look for info on this, do you? Well, drawing into an image file in Cocoa is pretty easy. You can either make an NSImage and the send it -lockFocus, then draw whatever you please, or if you need more control, you can make an NSBitmapImageRep and use +graphicsContextWithBitmapImageRep: to create a graphics context. NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:256 pixelsHigh:256 bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:0 bitsPerPixel: 0]; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:rep]; // You now have an NSBitmapImageRep with your drawing in it. You can do as you please with it from here on out. To draw gradients, on OS X 10.5 and later you can use NSGradient; otherwise you'll need to use a CGShading, which is a little trickier but still not difficult. *lightbulb* so the image could be _the box with rounded corners_? Well you could do it with a single background image, if you wanted, yes. That would probably work better than you might think too because PNG should be able to do a decent job of compressing it, even with a gradient fill. It won't work if you need to change the size of the box, obviously (unless you can use some of the recently added WebKit features, but that won't work for a public site since only WebKit supports it). If it needs to be resizable, you could split the image up into nine pieces and do with similar styles to before. The reason you'd need the extra divs in the case of a filled box is that you wouldn't want to set the background on the "box" part, because then that would show through under the corners. As a result, you'd need to set the styles up to tile the inner divs like this: The "content" div could simply have its z-index set above those of the corners (depending on the desired effect, obviously), and then use margin to keep it from going outside the rounded box. The nine piece method is (a lot) more complicated to set up, but it could be made to work if the size of the box itself varied. Is it possible to output it as a png, so the parts behind the rounded corners allow anything behind to show through? NSData *pngData = [rep representationUsingType:NSPNGFileType properties:nil]; [pngData writeToFile:@"MyFile.png" atomically:YES]; You could set the properties if you really wanted, but I don't think you need to. Like that? This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Robinson