rendered paste body//
// WaveView.m
// Wave
//
// Created by Isha on 20.09.11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "WaveView.h"
@implementation WaveView
@synthesize ySlider,ycSlider,xSlider;
#pragma mark init functions
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
NSLog(@"Init called");
NSLog(@"Myself %@", self);
}
return self;
}
- (void)initValues
{
x=400;
yc=50;
width=0;
y=200;
xSlider.value = x;
[ySlider setValue:y];
[ycSlider setValue:yc];
}
#pragma mark draw functions
- (void)drawRect:(CGRect)rect
{
NSLog(@"Myself %@", self);
if (x == 0 && yc == 0 || width== 0 || y == 0) {
[self initValues];
}
NSLog(@"x:%f y:%f yc:%f w: %f", x,y,yc,width);
NSLog(@"Slider: %f %f %f", xSlider.value, ySlider.value, ycSlider.value);
while (width<=rect.size.width) {
CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, width,y/2);
CGPathAddQuadCurveToPoint(path, nil, width+x/4, -yc,width+ x/2, y/2);
CGPathMoveToPoint(path, nil, width+x/2,y/2);
CGPathAddQuadCurveToPoint(path, nil, width+3*x/4, y+yc, width+x, y/2);
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathStroke);
width+=x;
}
NSLog(@"Jumping out!");
}
#pragma mark sliders
- (IBAction)changeSliderX
{
NSLog(@"Myself %@", self);
x = [xSlider value];
[self setNeedsDisplay];
}
- (IBAction)changeSliderY
{
y = [ySlider value];
[self setNeedsDisplay];
}
- (IBAction)changeSliderYC
{
yc = [ycSlider value];
[self setNeedsDisplay];
}
#pragma mark deallocations
- (void)dealloc
{
[super dealloc];
}
@end