Skip to main content
halp!
Source Link
Flambino
  • 1.1k
  • 8
  • 6

Obj-C++ / Cocoa, 777 678 668 657 643643 628 bytes

#include <Cocoa/Cocoa.h> float r;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=CGContext*c=(CGContextRefCGContext*)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColorNSGraphicsContext.currentContext.graphicsPort;CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(CGRect){cos(r)*38+50,sin(r-=pi/300)*38+50,1,1)});[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];self.needsDisplay=1;}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Edit: Saved another 14 bytes: Didn't need to assign the NSTimer instance to anything, and can apparently skip initializing r to zero.

Edit: Saved another 15 bytes: I can't stop. Send help.

Obj-C++ / Cocoa, 777 678 668 657 643 bytes

#include <Cocoa/Cocoa.h> float r;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Edit: Saved another 14 bytes: Didn't need to assign the NSTimer instance to anything, and can apparently skip initializing r to zero.

Obj-C++ / Cocoa, 777 678 668 657 643 628 bytes

#include <Cocoa/Cocoa.h> float r;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContext*c=(CGContext*)NSGraphicsContext.currentContext.graphicsPort;CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,(CGRect){cos(r)*38+50,sin(r-=pi/300)*38+50,1,1});[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{self.needsDisplay=1;}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Edit: Saved another 14 bytes: Didn't need to assign the NSTimer instance to anything, and can apparently skip initializing r to zero.

Edit: Saved another 15 bytes: I can't stop. Send help.

Can't stop golfing even though it's futile. I have a problem.
Source Link
Flambino
  • 1.1k
  • 8
  • 6

Obj-C++ / Cocoa, 777 678 668 657657 643 bytes

#include <Cocoa/Cocoa.h> float r=0;NSTimer*t;@implementationr;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));t=[NSTimer;[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Edit: Saved another 14 bytes: Didn't need to assign the NSTimer instance to anything, and can apparently skip initializing r to zero.

Obj-C++ / Cocoa, 777 678 668 657 bytes

#include <Cocoa/Cocoa.h> float r=0;NSTimer*t;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));t=[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Obj-C++ / Cocoa, 777 678 668 657 643 bytes

#include <Cocoa/Cocoa.h> float r;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Edit: Saved another 14 bytes: Didn't need to assign the NSTimer instance to anything, and can apparently skip initializing r to zero.

saved bytes through sheer will
Source Link
Flambino
  • 1.1k
  • 8
  • 6

Obj-C++ / Cocoa, 777 678 668668 657 bytes

#include <Cocoa/Cocoa.h> float r=0;NSTimer*t;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));t=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b=NSMakeRect(b={0,0,100,100)};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Obj-C++ / Cocoa, 777 678 668 bytes

#include <Cocoa/Cocoa.h> float r=0;NSTimer*t;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));t=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b=NSMakeRect(0,0,100,100);NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Obj-C++ / Cocoa, 777 678 668 657 bytes

#include <Cocoa/Cocoa.h> float r=0;NSTimer*t;@implementation V:NSView-(void)drawRect:(NSRect)d{CGContextRef c=(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];CGContextSetRGBFillColor(c,.5,0,.5,1);CGContextFillRect(c,CGRectMake(cos(r)*38+50,sin(r-=pi/300)*38+50,1,1));t=[NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(x)userInfo:0 repeats:0];}-(void)x{[self setNeedsDisplay:1];}@end int main(){NSRect b={0,0,100,100};NSWindow*w=[[NSWindow alloc]initWithContentRect:b styleMask:1 backing:2 defer:0];[w orderFront:0];w.backgroundColor=[NSColor whiteColor];w.contentView=[[V alloc]initWithFrame:b];[NSApp run];return 0;} 

So this is probably the worst way to do anything, but I figured I'd try.

Can be compiled on a Mac (mine anyway) with g++ -framework Cocoa file.mm and run from the terminal (ctrl-C to quit, since it's not an app).

screenshot

Edit: Saved 99 bytes: Fixed main() to run on OS X 10.10 (1st version only ran on 10.8), skipped translate/rotate in favor of plain trig calculations, stopped bothering with window placement, and other small stuff.

Edit: Saved another 10 bytes: Changed to just orderFront to display the window. Doesn't actually make it the front window, though, but neither did orderFrontAndMakeKey, so...

Edit: Saved another 11 bytes: Skipped NSMakeRect and found a digit that just had to go.

Saved 10 bytes
Source Link
Flambino
  • 1.1k
  • 8
  • 6
Loading
saved 99 bytes
Source Link
Flambino
  • 1.1k
  • 8
  • 6
Loading
Source Link
Flambino
  • 1.1k
  • 8
  • 6
Loading