diff --git a/objective-c/RandomCoreGraphicsGenerator/Info.plist b/objective-c/RandomCoreGraphicsGenerator/Info.plist new file mode 100644 index 0000000..077ebe9 --- /dev/null +++ b/objective-c/RandomCoreGraphicsGenerator/Info.plist @@ -0,0 +1,28 @@ + + + + + FSPluginMenuName + Convert to Grayscale RandomCG + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleName + ${PRODUCT_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.RandomCG + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + RandomCG + + diff --git a/objective-c/RandomCoreGraphicsGenerator/RandomCG.h b/objective-c/RandomCoreGraphicsGenerator/RandomCG.h new file mode 100644 index 0000000..d3ab654 --- /dev/null +++ b/objective-c/RandomCoreGraphicsGenerator/RandomCG.h @@ -0,0 +1,20 @@ +// +// RandomCG.h +// RandomCG +// +// Created by August Mueller on 10/15/07. +// Copyright Flying Meat Inc 2007 . All rights reserved. +// + + +#import +#import +#import "ACPlugin.h" + +#import "RandomCG.h" + +@interface RandomCG : NSObject { + +} + +@end diff --git a/objective-c/RandomCoreGraphicsGenerator/RandomCG.m b/objective-c/RandomCoreGraphicsGenerator/RandomCG.m new file mode 100644 index 0000000..190ee9a --- /dev/null +++ b/objective-c/RandomCoreGraphicsGenerator/RandomCG.m @@ -0,0 +1,111 @@ +// +// RandomCG.m +// RandomCG +// +// Created by August Mueller on 10/15/07. +// Copyright Flying Meat Inc 2007 . All rights reserved. +// + +#import "RandomCG.h" + +#define PI 3.14159265358979323846 + +@implementation RandomCG + ++ (id)plugin { + return [[[self alloc] init] autorelease]; +} + +- (void) willRegister:(id)pluginManager { + + [pluginManager addFilterMenuTitle:@"Random CG Calls" + withSuperMenuTitle:@"Generator" + target:self + action:@selector(make:userObject:) + keyEquivalent:@"" + keyEquivalentModifierMask:0 + userObject:nil]; +} + +- (void)didRegister { + +} + +- (CIImage*)make:(CIImage*)image userObject:(id)uo { + + int w = [image extent].size.width; + int h = [image extent].size.height; + + CGColorSpaceRef cs = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); + + CGContextRef context = CGBitmapContextCreate(nil, w, h, 8, 0, cs, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host); + + CGColorSpaceRelease(cs); + + // Fill with a random color + CGContextSetRGBFillColor(context, (rand()%256)/255.0, (rand()%256)/255.0, (rand()%256)/255.0, 1); + CGContextBeginPath(context); + CGContextAddRect(context, CGRectMake(0, 0, w, h)); + CGContextFillPath(context); + + for (int i = 0; i < 20; i++) { + int numberOfSegments = rand() % 8; + int j; + float sx, sy; + + CGContextBeginPath(context); + sx = rand()%w; sy = rand()%h; + CGContextMoveToPoint(context, rand()%w, rand()%h); + for (j = 0; j < numberOfSegments; j++) { + if (j % 2) { + CGContextAddLineToPoint(context, rand()%w, rand()%h); + } + else { + CGContextAddCurveToPoint(context, rand()%w, rand()%h, + rand()%w, rand()%h, rand()%h, rand()%h); + } + } + if(i % 2) { + CGContextAddCurveToPoint(context, rand()%w, rand()%h, + rand()%w, rand()%h, sx, sy); + CGContextClosePath(context); + CGContextSetRGBFillColor(context, (float)(rand()%256)/255, + (float)(rand()%256)/255, (float)(rand()%256)/255, + (float)(rand()%256)/255); + CGContextFillPath(context); + } + else { + CGContextSetLineWidth(context, (rand()%10)+2); + CGContextSetRGBStrokeColor(context, (float)(rand()%256)/255, + (float)(rand()%256)/255, (float)(rand()%256)/255, + (float)(rand()%256)/255); + CGContextStrokePath(context); + } + } + + + CGImageRef imageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + CIImage *returnImage = [CIImage imageWithCGImage:imageRef]; + + CGImageRelease(imageRef); + + return returnImage; +} + +- (NSNumber*)worksOnShapeLayers:(id)userObject { + return [NSNumber numberWithBool:NO]; +} + +- (NSNumber*)validateForLayer:(id)layer { + + if ([layer layerType] == ACBitmapLayer) { + [NSNumber numberWithBool:YES]; + } + + return [NSNumber numberWithBool:NO]; +} + +@end diff --git a/objective-c/RandomCoreGraphicsGenerator/RandomCG.xcodeproj/project.pbxproj b/objective-c/RandomCoreGraphicsGenerator/RandomCG.xcodeproj/project.pbxproj new file mode 100644 index 0000000..78eb8b0 --- /dev/null +++ b/objective-c/RandomCoreGraphicsGenerator/RandomCG.xcodeproj/project.pbxproj @@ -0,0 +1,260 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; + CCF900820C29E1CB00BA85E7 /* RandomCG.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF900810C29E1CB00BA85E7 /* RandomCG.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 8D5B49B6048680CD000E48DA /* RandomCG.acplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RandomCG.acplugin; sourceTree = BUILT_PRODUCTS_DIR; }; + CC39445815FED36B0057C496 /* ACPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ACPlugin.h; path = ../../headers/ACPlugin.h; sourceTree = ""; }; + CCF900720C29E19900BA85E7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CCF900800C29E1CB00BA85E7 /* RandomCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomCG.h; sourceTree = ""; }; + CCF900810C29E1CB00BA85E7 /* RandomCG.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RandomCG.m; sourceTree = ""; }; + D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D5B49B3048680CD000E48DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* acplugins */ = { + isa = PBXGroup; + children = ( + 08FB77AFFE84173DC02AAC07 /* Classes */, + 32C88E010371C26100C91783 /* Other Sources */, + 089C167CFE841241C02AAC07 /* Resources */, + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, + 19C28FB8FE9D52D311CA2CBB /* Products */, + ); + name = acplugins; + sourceTree = ""; + }; + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, + ); + name = "Frameworks and Libraries"; + sourceTree = ""; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + ); + name = Resources; + sourceTree = ""; + }; + 08FB77AFFE84173DC02AAC07 /* Classes */ = { + isa = PBXGroup; + children = ( + CCF900800C29E1CB00BA85E7 /* RandomCG.h */, + CCF900810C29E1CB00BA85E7 /* RandomCG.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 089C167FFE841241C02AAC07 /* AppKit.framework */, + D2F7E65807B2D6F200F64583 /* CoreData.framework */, + 089C1672FE841209C02AAC07 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FB8FE9D52D311CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D5B49B6048680CD000E48DA /* RandomCG.acplugin */, + ); + name = Products; + sourceTree = ""; + }; + 32C88E010371C26100C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + CC39445815FED36B0057C496 /* ACPlugin.h */, + CCF900720C29E19900BA85E7 /* Info.plist */, + ); + name = "Other Sources"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D5B49AC048680CD000E48DA /* RandomCG */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "RandomCG" */; + buildPhases = ( + 8D5B49AF048680CD000E48DA /* Resources */, + 8D5B49B1048680CD000E48DA /* Sources */, + 8D5B49B3048680CD000E48DA /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RandomCG; + productInstallPath = "$(HOME)/Library/Bundles"; + productName = acplugins; + productReference = 8D5B49B6048680CD000E48DA /* RandomCG.acplugin */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "RandomCG" */; + compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + en, + ); + mainGroup = 089C166AFE841209C02AAC07 /* acplugins */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 8D5B49AC048680CD000E48DA /* RandomCG */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D5B49AF048680CD000E48DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D5B49B1048680CD000E48DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + CCF900820C29E1CB00BA85E7 /* RandomCG.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB913C08733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + OTHER_LDFLAGS = ( + "-undefined", + dynamic_lookup, + ); + PRODUCT_NAME = RandomCG; + WRAPPER_EXTENSION = acplugin; + }; + name = Release; + }; + 1DEB914008733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = macosx; + }; + name = Release; + }; + CC2C7CA00B0BC41F00A22730 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH_ACTUAL)"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + PREBINDING = NO; + SDKROOT = macosx; + }; + name = Debug; + }; + CC2C7CA10B0BC41F00A22730 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_MODEL_TUNING = G5; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_SHADOW = YES; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + OTHER_LDFLAGS = ( + "-undefined", + dynamic_lookup, + ); + PRODUCT_NAME = RandomCG; + WRAPPER_EXTENSION = acplugin; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "RandomCG" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913C08733D840010E9CD /* Release */, + CC2C7CA10B0BC41F00A22730 /* Debug */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "RandomCG" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB914008733D840010E9CD /* Release */, + CC2C7CA00B0BC41F00A22730 /* Debug */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/objective-c/RandomCoreGraphicsGenerator/RandomCG.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/objective-c/RandomCoreGraphicsGenerator/RandomCG.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..a8d227d --- /dev/null +++ b/objective-c/RandomCoreGraphicsGenerator/RandomCG.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + +