[MacRuby-devel] Quartz 2D Graphics problem

Colin Thomas-Arnold colinta at gmail.com
Sun Oct 21 09:44:37 PDT 2012


You can certainly compile a group of stuff as a framework, and add that framework to your project, but I've never tried to just toss in .h/.m files and access them from macruby.

Can anyone touch on that?  I'm interested to hear what can be done there...


AFA translating your code into Obj-C...


Here's the short version:

self.context = [[NSGraphics currentContext] graphicsPort];



And here's the long version!


// the header file, YourClass.h

@interface YourClass : ParentClass

@property (assign, nonatomic) CGContextRef context;
// or void* instead of CGContextRef, but graphicsPort returns a CGContextRef

@end



// the implementation file, YourClass.m

#import "YourClass.h"

@implementation YourClass

@synthesize context;

- drawRect:(CGRect)rect
{
  self.context = [[NSGraphics currentContext] graphicsPort];
}

@end




@colinta
colinta.com
github.com/colinta




On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:

> Hi Mark,
> 
> Unfortunately, I am not very familiar with objective C syntax. Is it easy to mix objective C statements with MacRuby?
> For example, How would code the @context = NSGraphicsContext.currentContext.graphicsPort in objective C?
> 
> Thanks,
> Bob Rice

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20121021/72f93f79/attachment-0001.html>


More information about the MacRuby-devel mailing list