This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE FUNCTION atan2! (y AS DOUBLE, x AS DOUBLE) | |
DECLARE SUB PieSlice2 (theta1 AS SINGLE, theta2 AS SINGLE, x AS SINGLE, y AS SINGLE, ro AS SINGLE, ri AS SINGLE) | |
DECLARE SUB PieSlice (theta1 AS SINGLE, theta2 AS SINGLE, x AS SINGLE, y AS SINGLE, orad AS SINGLE, irad AS SINGLE) | |
' for PieSlice2 | |
CONST sep = 10 | |
DEF fnphi (x!, ri!) = ATN(x! / (2 * ri)) | |
DEF fnAx (theta!, ri!) = ri! * COS(theta! + fnphi(sep, ri!)) | |
DEF fnAy (theta!, ri!) = ri! * SIN(theta! + fnphi(sep, ri!)) | |
DEF fnBx (theta!, ri!) = ri! * COS(theta! - fnphi(sep, ri!)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ pieSliceWithCentre: (CGPoint) c innerRadius: (double) ir outerRadius: (double) or | |
startAngle: (double) theta1 endAngle: (double) theta2 { | |
UIBezierPath *path = [UIBezierPath bezierPath]; | |
if (path) { | |
[path moveToPoint: CGPointMake(cos(theta1)*ir, sin(theta1)*or)]; | |
[path addLineToPoint: CGPointMake(cos(theta1)*or, sin(theta1)*or)]; | |
[path addArcWithCenter: CGPointZero radius: or startAngle: theta1 endAngle: theta2 clockwise: NO]; | |
[path addLineToPoint: CGPointMake(cos(theta2)*ir, sin(theta2)*ir)]; | |
[path addArcWithCenter: CGPointZero radius: ir startAngle: theta2 endAngle:theta1 clockwise: NO]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) awakeFromNib { | |
self.opaque = YES; | |
self.clearsContextBeforeDrawing = YES; | |
[self setNeedsDisplay]; | |
NSBundle *main = [NSBundle mainBundle]; | |
// Open PDF | |
CGPDFDocumentRef doc = CGPDFDocumentCreateWithURL((CFURLRef)[main URLForResource: @"NC.pdf" withExtension: nil]); | |
if (doc == NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSFileHandle (print) | |
- (void) printf: (NSString*) format, ... | |
{ | |
NSString *output; | |
va_list ap; | |
va_start(ap, format); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program euler002 | |
implicit none | |
integer :: i = 0 | |
integer :: f = 0 | |
integer :: s = 0 | |
do | |
i = i + 1 | |
f = fib(i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Take: | |
1 2 3 | |
4 5 6 | |
7 8 9 | |
Turn Into: | |
0 0 0 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class World(object): | |
def __init__(self): | |
self.verts_id = GLuint() | |
glGenBuffers(1, self.verts_id) | |
self.mesh = [] | |
for x in xrange(SIZE): | |
for z in xrange(SIZE): | |
self.mesh.extend((float(SIZE//2 - x), 0.0, float(SIZE//2 - z))) | |
data = (GLfloat*len(self.mesh))(*self.mesh) | |
glBindBuffer(GL_ARRAY_BUFFER, self.verts_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import division | |
from pyglet import clock, font, image, window, text | |
from pyglet.gl import * | |
import numpy | |
SIZE = 64 | |
TWO_PI = 2.0 * 3.1415926535 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CIAdditionCompositing - Adds color components to achieve a brightening effect. This filter is typically used to add highlights and lens flare effects. | |
CIAffineClamp - Performs an affine transform on a source image and then clamps the pixels at the edge of the transformed image, extending them outwards. This filter performs similarly to the CIAffineTransform filter except that it produces an image with infinite extent. You can use this filter when you need to blur an image but you want to avoid a soft, black fringe along the edges. | |
CIAffineTile - Applies an affine transform to an image and then tiles the transformed image. | |
CIAffineTransform - Applies an affine transform to an image. You can scale, translate, or rotate the input image. You can also apply a combination of these operations. | |
CIAreaAverage - Calculates the average color for the specified area in an image, returning the result in a pixel. | |
CIAreaHistogram - Calculates a histogram for the specified area in an image, returning the result in a 1D image. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CIFilter *filter = [CIFilter filterWithName: @"CIZoomBlur"]; | |
[filter setDefaults]; | |
[filter setValue: [CIVector vectorWithX: self.title.bounds.size.width / 2 | |
Y: self.title.bounds.size.height / 2] | |
forKey: @"inputCenter"]; | |
[filter setValue: [NSNumber numberWithFloat: 0.0] | |
forKey: @"inputAmount"]; | |
// [filter setValue: [NSNumber numberWithFloat: 90.0] forKey: @"inputAngle"]; | |
[filter setName: @"zoomBlur"]; | |
[self.title setFilters: [NSArray arrayWithObject: filter]]; |