mirror of
https://github.com/ksherlock/TwoTerm.git
synced 2026-04-20 19:16:35 +00:00
change settings for visual effects
git-svn-id: svn://qnap.local/TwoTerm/trunk@2025 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// ExampleView.m
|
||||
// 2Term
|
||||
//
|
||||
// Created by Kelvin Sherlock on 2/6/2011.
|
||||
// Copyright 2011 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ExampleView.h"
|
||||
|
||||
#import "ScanLineFilter.h"
|
||||
#import "CharacterGenerator.h"
|
||||
|
||||
@implementation ExampleView
|
||||
|
||||
@synthesize lighten = _lighten;
|
||||
@synthesize darken = _darken;
|
||||
@synthesize blur = _blur;
|
||||
@synthesize foregroundColor = _foregroundColor;
|
||||
|
||||
|
||||
-(void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
_foregroundColor = [[NSColor greenColor] retain];
|
||||
_charGenerator = [[CharacterGenerator generator] retain];
|
||||
[self setWantsLayer: YES];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_foregroundColor release];
|
||||
[_charGenerator release];
|
||||
[super dealloc];
|
||||
|
||||
}
|
||||
|
||||
-(BOOL)isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
CGFloat paddingLeft = 10.0;
|
||||
CGFloat paddingTop = 10.0;
|
||||
|
||||
const char *string = "Two Term";
|
||||
|
||||
NSSize size = [_charGenerator characterSize];
|
||||
|
||||
[super drawRect: dirtyRect];
|
||||
|
||||
[_foregroundColor set];
|
||||
|
||||
for (unsigned i = 0; string[i]; ++i)
|
||||
{
|
||||
[_charGenerator drawCharacter: string[i] atPoint: NSMakePoint( i * size.width + paddingLeft, paddingTop)];
|
||||
}
|
||||
|
||||
// draw inversed on the next line.
|
||||
|
||||
for (unsigned i = 0; string[i]; ++i)
|
||||
{
|
||||
[_foregroundColor set];
|
||||
NSRectFill(NSMakeRect( i * size.width + paddingLeft, size.height + paddingTop, size.width, size.height));
|
||||
|
||||
[_color set];
|
||||
[_charGenerator drawCharacter: string[i] atPoint: NSMakePoint( i * size.width + paddingLeft, size.height + paddingTop)];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)updateEffects
|
||||
{
|
||||
|
||||
NSMutableArray *filters;
|
||||
CIFilter *filter;
|
||||
|
||||
filters = [NSMutableArray arrayWithCapacity: 3];
|
||||
|
||||
|
||||
//add the scanlines
|
||||
|
||||
filter = [[ScanLineFilter new] autorelease];
|
||||
[filter setValue: [NSNumber numberWithFloat: _darken] forKey: @"inputDarken"];
|
||||
[filter setValue: [NSNumber numberWithFloat: _lighten] forKey: @"inputLighten"];
|
||||
[filters addObject: filter];
|
||||
|
||||
//blur it a bit...
|
||||
|
||||
filter = [CIFilter filterWithName: @"CIGaussianBlur"];
|
||||
[filter setDefaults];
|
||||
[filter setValue: [NSNumber numberWithFloat: _blur] forKey: @"inputRadius"];
|
||||
|
||||
[filters addObject: filter];
|
||||
|
||||
|
||||
|
||||
[self setContentFilters: filters];
|
||||
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user