Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ExpoViewController.m
- // bozar
- //
- // Created by lennert van sever on 21/05/15.
- // Copyright (c) 2015 lennert van sever. All rights reserved.
- //
- #import "ExpoViewController.h"
- #import "Cirkel.h"
- #import "HetAlgoritme.h"
- #import "DetailViewController.h"
- #import <QuartzCore/QuartzCore.h>
- #import "tabBarControl.h"
- @interface ExpoViewController ()
- @property UIView *circleViewUser;
- @property UIView *testStuk4;
- @property Cirkel *user;
- @property NSMutableArray *cirkleArray;
- @property UIImageView *plattegrond;
- @property CGFloat xScherm;
- @property NSTimer *myTimer;
- @property (weak, nonatomic) IBOutlet UIButton *voorButton;
- @property (weak, nonatomic) IBOutlet UIButton *achterButton;
- @property (weak, nonatomic) IBOutlet UIButton *linksButton;
- @property (weak, nonatomic) IBOutlet UIButton *rechtsButton;
- @property CGFloat yScherm;
- @property CGFloat posX;
- @property CGFloat posY;
- @property CGFloat stukPosX;
- @property CGFloat stukPosY;
- @property float grootteC;
- @property float eersteGrootteC;
- @property NSMutableArray *posXcirkels;
- @property NSMutableArray *posYcirkels;
- @property NSMutableArray *ratio;
- @property CAShapeLayer *lineShape;
- @property CAShapeLayer *lineShape2;
- @property CGMutablePathRef linePath;
- @property double posx;
- @property double posy;
- @property double d;
- @property double posx2;
- @property double posy2;
- @property double d2;
- @property double posx3;
- @property double posy3;
- @property double d3;
- @end
- @implementation ExpoViewController
- #define CGRectSetPos( r, x, y ) CGRectMake( x, y, r.size.width, r.size.height )
- - (void)viewDidLoad {
- [super viewDidLoad];
- tabBarControl *tabBar = (tabBarControl *)self.tabBarController;
- NSLog(@"expo id: %d", tabBar.expoId);
- self.cirkleArray = [[NSMutableArray alloc] init];
- CGRect screenRect = [[UIScreen mainScreen] bounds]; //maakt een rect van het scherm
- self.xScherm = screenRect.size.width; //breedte totaal scherm
- self.yScherm = screenRect.size.height; //hoogte scherm
- UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
- activityIndicator.center = CGPointMake(self.view.frame.size.width / 2.0, self.view.frame.size.height / 2.0);
- [self.view addSubview: activityIndicator];
- [activityIndicator startAnimating];
- NSURLSession *startJSON = [NSURLSession sharedSession];
- NSString *urlJson = [NSString stringWithFormat:@"http://iwtsl.ehb.be/~glen.van.haver/Bozar/kunstwerkenExpositieJSON.php?expositieId=%d", tabBar.expoId];
- [[startJSON dataTaskWithURL:[NSURL URLWithString:urlJson]
- completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
- NSDictionary* json = [NSJSONSerialization
- JSONObjectWithData:data
- options:kNilOptions
- error:&error];
- dispatch_async(dispatch_get_main_queue(), ^{
- for(int i = 0; i < [json count]; i++){
- NSString *selectie = [NSString stringWithFormat:@"kunstwerk%d", i];
- NSDictionary *expositieAll = [json objectForKey:selectie];
- NSString *kunstId = [expositieAll objectForKey:@"kunstwerkId"];
- NSString *kunstPosX = [expositieAll objectForKey:@"kunstwerkLatitude"];
- NSString *kunstPosY = [expositieAll objectForKey:@"kunstwerkLongitude"];
- NSString *kunstAfbeelding = [expositieAll objectForKey:@"kunstwerkFoto"];
- NSString *kunstKleur = [expositieAll objectForKey:@"kunstwerkZaalKleur"];
- NSLog(@"%@", [self colorFromHexString:kunstKleur]);
- Cirkel *cirkelObject = [[Cirkel alloc] init];
- cirkelObject.cirkelId = [kunstId intValue];
- cirkelObject.posXcirkel = self.xScherm/2+[kunstPosX floatValue]*(self.xScherm/4);
- cirkelObject.posYcirkel = self.yScherm/2-[kunstPosY floatValue]*(self.xScherm/4);
- cirkelObject.grootte = 20;
- cirkelObject.kleur = [UIColor whiteColor];
- cirkelObject.ani = YES;
- cirkelObject.toe = YES;
- cirkelObject.padAfbeedling = [NSString stringWithFormat:@"http://iwtsl.ehb.be/~glen.van.haver/Bozar/img/kunstwerken/%@", kunstAfbeelding];
- cirkelObject.kleurBorder = [self colorFromHexString:kunstKleur];
- [self.cirkleArray addObject:cirkelObject];
- }
- [activityIndicator removeFromSuperview];
- self.posXcirkels = [[NSMutableArray alloc] init];
- self.ratio = [[NSMutableArray alloc] init];
- self.posYcirkels = [[NSMutableArray alloc] init];
- self.grootteC = 1;
- self.posX = self.xScherm/2-50/2;
- self.posY = self.yScherm/2-50/2;
- NSLog(@"count %lu", (unsigned long)[self.cirkleArray count]);
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- UIView *itNaam = [itObject cirkelNaam];
- itNaam = [self dynamischeCirkel:[itObject posXcirkel] positieY:[itObject posYcirkel] grootte:[itObject grootte] kleur:[itObject kleur] kleurBorder:[itObject kleurBorder] afbeeldingNaam:[itObject padAfbeedling] variabeleNaam:itNaam metAnimatie:[itObject ani] meteenToevoegen:[itObject toe] nrCirkel:i cirkelId:[itObject cirkelId]];
- itObject.cirkelNaam = itNaam;
- }
- });
- }] resume];
- self.user = [[Cirkel alloc] init];
- self.user.cirkelId = -1;
- self.user.cirkelNaam = self.circleViewUser;
- self.user.posXcirkel = self.xScherm/2;//+30;
- self.user.posYcirkel = self.yScherm/2;//+30;
- self.user.grootte = 20;
- self.user.kleur = [self colorFromHexString:@"#48CFAD"];
- self.user.ani = YES;
- self.user.toe = YES;
- self.user.kleurBorder = nil;
- NSLog(@"%f", self.xScherm/350);
- self.plattegrond = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plattegrond belgie.png"]];
- self.plattegrond.transform = CGAffineTransformMakeScale(self.xScherm/400,self.xScherm/400);
- self.plattegrond.center = CGPointMake(self.xScherm/2+10*(self.xScherm/4), self.yScherm/2-8.5*(self.xScherm/4));
- [self.view addSubview:self.plattegrond];
- //self.circleViewUser = [[UIView alloc] initWithFrame:CGRectMake(self.xScherm/2-50/2,self.yScherm/2-50/2,50,50)];
- self.user.cirkelNaam = [self cirkel:self.user.posXcirkel positieY:self.user.posYcirkel grootte:self.user.grootte kleur:self.user.kleur kleurBorder:self.user.kleurBorder afbeeldingNaam:nil variabeleNaam:self.user.cirkelNaam metAnimatie:self.user.ani meteenToevoegen:self.user.toe kunstWerk:NO nrCirkel:-1 cirkelId:-1];
- }
- - (UIColor *)colorFromHexString:(NSString *)hexString { //http://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string helemaal overgenomen. Om van hex naar UIColor te gaan
- unsigned rgbValue = 0;
- NSScanner *scanner = [NSScanner scannerWithString:hexString];
- [scanner setScanLocation:1]; // bypass '#' character
- [scanner scanHexInt:&rgbValue];
- return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0];
- }
- -(UIView*)dynamischeCirkel:(float)posX positieY:(float)posY grootte:(int)bCirkel kleur:(UIColor*)kleur kleurBorder:(UIColor*)border afbeeldingNaam:(NSString *)img variabeleNaam:(UIView*)varC metAnimatie:(BOOL)ani meteenToevoegen:(BOOL)toe nrCirkel:(int)nr cirkelId:(int)id {
- float schuineZijde = sqrt(((posX-self.posX)*(posX-self.posX)+(posY-self.posY)*(posY-self.posY))); //pythagoras!!
- float ratioC = (500-schuineZijde)/5; //grootte berekenen afhankelijk van de afstand tussen de gebruiker
- if(ratioC < 0){
- ratioC = 0;
- }
- Cirkel *deze = [self.cirkleArray objectAtIndex:nr];
- /*if(posX > -50 && posY > -50 && posX < self.xScherm+50 && posY < self.xScherm+50){
- deze.grootte = ratioC; //de breedte zetten die net is aangepast
- }
- else{*/
- ratioC = 50;
- deze.grootte = ratioC;
- //}
- deze.posXcirkel = posX-ratioC/2;
- deze.posYcirkel = posY-ratioC/2;
- // NSLog(@"ratio %f", ratioC);
- return [self cirkel:posX positieY:posY grootte:ratioC kleur:kleur kleurBorder:border afbeeldingNaam:img variabeleNaam:varC metAnimatie:ani meteenToevoegen:toe kunstWerk:YES nrCirkel:nr cirkelId:id];
- }
- -(UIView*)cirkel:(float)posX positieY:(float)posY grootte:(int)bCirkel kleur:(UIColor*)kleur kleurBorder:(UIColor*)border afbeeldingNaam:(NSString *)img variabeleNaam:(UIView*)varC metAnimatie:(BOOL)ani meteenToevoegen:(BOOL)toe kunstWerk:(BOOL)kunst nrCirkel:(int)nr cirkelId:(int)id{
- varC = [[UIView alloc] initWithFrame:CGRectMake(posX-bCirkel/2,posY-bCirkel/2,bCirkel,bCirkel)]; //de variabele zorgen dat hij op elke device perfect in het midden staat.
- varC.alpha = 1;
- varC.layer.cornerRadius = bCirkel/2; //zorgt ervoor om de
- varC.backgroundColor = kleur;
- if(kunst){
- varC.layer.masksToBounds = NO;
- varC.layer.shadowOffset = CGSizeMake(2, 2);
- varC.layer.shadowRadius = 2;
- varC.layer.shadowOpacity = 0.7; //http://stackoverflow.com/questions/805872/how-do-i-draw-a-shadow-under-a-uiview om een shadow te tekenen
- }
- if(ani){
- varC.transform = CGAffineTransformMakeScale(0,0);
- }
- if(toe){
- [self.view addSubview:varC];
- }
- if(kunst){
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]
- initWithTarget:self action:@selector(processTap:)];
- [varC setTag:id]; //set tag value
- [varC addGestureRecognizer:tap];
- [varC setUserInteractionEnabled:YES];
- UIImageView *imageHolder = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, bCirkel, bCirkel)];
- NSURL *url = [NSURL URLWithString:img];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [UIImage imageWithData:data];
- imageHolder.image = image;
- imageHolder.clipsToBounds = YES;
- imageHolder.layer.cornerRadius = bCirkel/2;
- imageHolder.transform = CGAffineTransformMakeScale(0.85,0.85); //afbeelding kleiner maken
- UIView *borderCirkel = [[UIView alloc] initWithFrame:CGRectMake(0,0,bCirkel,bCirkel)];
- borderCirkel.layer.cornerRadius = bCirkel/2;
- borderCirkel.backgroundColor = [UIColor clearColor];
- borderCirkel.layer.borderColor = border.CGColor;
- borderCirkel.layer.borderWidth = 1.5;
- borderCirkel.transform = CGAffineTransformMakeScale(0.95,0.95);
- [varC addSubview:borderCirkel];
- [varC addSubview:imageHolder];
- }
- self.eersteGrootteC = bCirkel/2;
- return varC;
- }
- - (void)processTap:(UIGestureRecognizer *)sender //http://stackoverflow.com/questions/11148415/how-to-pass-argument-to-action-in-uigesturerecognizer-initwithtarget-action voor de tab op de view
- {
- // NSLog(@"tabbed!!");
- // NSLog(@"%ld", (long)sender.view.tag);
- sender.view.layer.zPosition = 5;
- [UIView animateWithDuration:.5 animations:^{
- //sender.view.layer.cornerRadius = 0;
- NSArray *childViews = [sender.view subviews];
- for(int i = 0; i < [childViews count]; i++){
- UIView *childView = [childViews objectAtIndex:i];
- childView.transform = CGAffineTransformMakeScale(.1,.1);
- }
- sender.view.transform = CGAffineTransformMakeScale(40,40);
- sender.view.clipsToBounds = NO;
- } completion:^(BOOL finished){
- DetailViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
- viewController.kunstId = (int)sender.view.tag;
- [self.navigationController pushViewController:viewController animated:NO];
- sender.view.layer.zPosition = 1;
- NSArray *childViews = [sender.view subviews];
- for(int i = 0; i < [childViews count]; i++){
- UIView *childView = [childViews objectAtIndex:i];
- if(i == 1){
- childView.transform = CGAffineTransformMakeScale(.85,.85);
- }
- else{
- childView.transform = CGAffineTransformMakeScale(.90,.90);
- }
- }
- }];
- }
- /*- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- NSLog(@"segue");
- }
- */
- - (void)viewDidAppear:(BOOL)animated{
- [UIView animateWithDuration:1 animations:^{
- self.user.cirkelNaam.transform = CGAffineTransformMakeScale(1,1);
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- UIView *itNaam = [itObject cirkelNaam];
- itNaam.transform = CGAffineTransformMakeScale(1,1);
- }
- } completion:^(BOOL finished){
- self.lineShape.lineWidth = 1;
- CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
- pathAnimation.duration = 1.0f;
- pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
- pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
- [self.lineShape addAnimation:pathAnimation forKey:@"strokeEnd"]; //http://stackoverflow.com/questions/15651717/how-to-animate-cashapelayer-path-and-fillcolor voor de animatie
- //http://stackoverflow.com/questions/5370557/draw-line-using-cgcontext hoe een lijn te tekenen
- }];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [UIView animateWithDuration:1 animations:^{ //http://www.raywenderlich.com/2454/uiview-tutorial-for-ios-how-to-use-uiview-animation om animatie te gebruiken.
- self.circleViewUser.transform = CGAffineTransformMakeScale(0,0);
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- UIView *itNaam = [itObject cirkelNaam];
- itNaam.transform = CGAffineTransformMakeScale(0,0);
- }
- } completion:^(BOOL finished){
- NSLog(@"%@", @"animatie gedaan");
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)handleZoom:(UIPinchGestureRecognizer *)recognizer{
- /*NSLog(@"schaal %f", [recognizer scale]);
- NSLog(@"Snelheid %f", [recognizer velocity]);
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- UIView *itNaam = [itObject cirkelNaam];
- itNaam.transform = CGAffineTransformMakeScale([recognizer scale], [recognizer scale]);
- self.plattegrond.transform = CGAffineTransformMakeScale(self.plattegrond.transform.a+[recognizer velocity]/1000, self.plattegrond.transform.d+[recognizer velocity]/1000);
- }*/
- }
- -(void)handleRotation:(UIRotationGestureRecognizer *)recognizer{
- // CGFloat snelheid = [recognizer velocity];
- CGFloat rotatie = [recognizer rotation];
- // NSLog(@"x: %f", snelheid);
- // NSLog(@"x: %f", self.xScherm/2+cos(rotatie));
- // self.view.transform=CGAffineTransformRotate(self.view.transform, rotatie);
- // NSLog(@"y: %f", self.yScherm/2+sin(rotatie)*100);
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- UIView *itNaam = [itObject cirkelNaam];
- float posXf = [[self.posXcirkels objectAtIndex:i] floatValue];
- float posYf = [[self.posYcirkels objectAtIndex:i] floatValue];
- float rotX = self.xScherm/2-25;
- float rotY = self.yScherm/2-25;
- float schuineZijde = sqrt(((posXf-rotX)*(posXf-rotX)+(posYf-rotY)*(posYf-rotY)));
- float angle = atan2(posYf-rotY, posXf-rotX);
- float verplaatsingX = schuineZijde * cos(angle+rotatie/20) + rotX;
- float verplaatsingY = schuineZijde * sin(angle+rotatie/20) + rotY;
- float rotXI = self.xScherm/2;
- float rotYI = self.yScherm/2;
- float schuineZijdeI = sqrt(((self.plattegrond.center.x-rotXI)*(self.plattegrond.center.x-rotXI)+(self.plattegrond.center.y-rotYI)*(self.plattegrond.center.y-rotYI)));
- float angleI = atan2(self.plattegrond.center.y-rotYI, self.plattegrond.center.x-rotXI);
- float factorI = 140;
- float verplaatsingXI = schuineZijdeI * cos(angleI+rotatie/factorI) + rotXI;
- float verplaatsingYI = schuineZijdeI * sin(angleI+rotatie/factorI) + rotYI;
- //NSLog(@"angle %f", angleI);
- NSLog(@"%f", schuineZijdeI);
- posXf = verplaatsingX;
- posYf = verplaatsingY;
- itNaam.frame = CGRectSetPos(itNaam.frame, posXf, posYf);
- self.plattegrond.center = CGPointMake(verplaatsingXI, verplaatsingYI);
- self.plattegrond.transform = CGAffineTransformRotate(self.plattegrond.transform, rotatie/factorI);
- [self.posXcirkels replaceObjectAtIndex:i withObject:[NSNumber numberWithFloat:posXf]];
- [self.posYcirkels replaceObjectAtIndex:i withObject:[NSNumber numberWithFloat:posYf]];
- }
- /*[self.lineShape removeFromSuperlayer];
- self.lineShape = nil;
- self.linePath = nil;
- self.linePath = CGPathCreateMutable();
- self.lineShape = [CAShapeLayer layer];
- self.lineShape.lineWidth = 1;
- self.lineShape.lineCap = kCALineCapRound;
- self.lineShape.strokeColor = [[UIColor blackColor] CGColor];
- self.lineShape.fillColor = [[UIColor clearColor] CGColor];
- float x = [[self.posXcirkels objectAtIndex:0] floatValue]; float y = [[self.posYcirkels objectAtIndex:0] floatValue];
- int toX = [[self.posXcirkels objectAtIndex:1] floatValue]; int toY = [[self.posYcirkels objectAtIndex:1] floatValue];
- int toX2 = [[self.posXcirkels objectAtIndex:2] floatValue]; int toY2 = [[self.posYcirkels objectAtIndex:2] floatValue];
- CGPathMoveToPoint(self.linePath, NULL, x+20, y+20);
- CGPathAddLineToPoint(self.linePath, NULL, toX+30, toY+30);
- CGPathAddLineToPoint(self.linePath, NULL, toX+30, toY+30);
- CGPathAddLineToPoint(self.linePath, NULL, toX2+20, toY2+20);
- self.lineShape.path = self.linePath;
- CGPathRelease(self.linePath);
- self.lineShape.zPosition = -1;
- [self.view.layer addSublayer:self.lineShape];*/
- }
- - (void)handlePan:(UIPanGestureRecognizer *)recognizer{
- CGFloat snelheidX = [recognizer velocityInView:self.view].x;
- CGFloat snelheidY = [recognizer velocityInView:self.view].y;
- recognizer.maximumNumberOfTouches = 1;
- if([recognizer maximumNumberOfTouches] == 1){
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- UIView *itNaam = [itObject cirkelNaam];
- float posXf = [[self.posXcirkels objectAtIndex:i] floatValue];
- // float snelheidAanpassenY = fabsf(((self.posX-posXf)/self.xScherm));
- float posYf = [[self.posYcirkels objectAtIndex:i] floatValue];
- // float snelheidAanpassenX = fabsf(((self.posY-posYf)/self.yScherm));
- posXf += snelheidX/290;
- posYf += snelheidY/290;
- float schuineZijde;
- float ratioC = 0.0;
- float eersteRatio = 0.0;
- if(posXf > -50 && posYf > -50 && posXf < self.xScherm+50 && posYf < self.xScherm+50){
- schuineZijde = sqrt(((posXf-self.posX)*(posXf-self.posX)+(posYf-self.posY)*(posYf-self.posY))); //pythagoras!!
- ratioC = (self.yScherm-schuineZijde)/50; //grootte berekenen afhankelijk van de afstand tussen de gebruiker
- eersteRatio = [[self.ratio objectAtIndex:0] floatValue];
- }
- if(posXf > -50 && posYf > -50 && posXf < self.xScherm+50 && posYf < self.xScherm+50){
- //NSLog(@"controle %f", posXf);
- itNaam.transform = CGAffineTransformMakeScale(ratioC/eersteRatio, ratioC/eersteRatio);
- }
- else{
- itNaam.transform = CGAffineTransformMakeScale(1, 1);
- }
- NSLog(@"%f", self.plattegrond.center.x);
- float erbijX = self.plattegrond.center.x + snelheidX/1990;
- float erbijY = self.plattegrond.center.y + snelheidY/1990;
- self.plattegrond.center = CGPointMake(erbijX, erbijY);
- itNaam.frame = CGRectSetPos(itNaam.frame, posXf, posYf);
- [self.posXcirkels replaceObjectAtIndex:i withObject:[NSNumber numberWithFloat:posXf]];
- [self.posYcirkels replaceObjectAtIndex:i withObject:[NSNumber numberWithFloat:posYf]];
- }
- /*[self.lineShape removeFromSuperlayer];
- self.lineShape = nil;
- self.linePath = nil;
- self.linePath = CGPathCreateMutable();
- self.lineShape = [CAShapeLayer layer];
- self.lineShape.lineWidth = 1;
- self.lineShape.lineCap = kCALineCapRound;
- self.lineShape.strokeColor = [[UIColor blackColor] CGColor];
- self.lineShape.fillColor = [[UIColor clearColor] CGColor];
- float x = [[self.posXcirkels objectAtIndex:0] floatValue]; float y = [[self.posYcirkels objectAtIndex:0] floatValue];
- int toX = [[self.posXcirkels objectAtIndex:1] floatValue]; int toY = [[self.posYcirkels objectAtIndex:1] floatValue];
- int toX2 = [[self.posXcirkels objectAtIndex:2] floatValue]; int toY2 = [[self.posYcirkels objectAtIndex:2] floatValue];
- CGPathMoveToPoint(self.linePath, NULL, x+20, y+20);
- CGPathAddLineToPoint(self.linePath, NULL, toX+30, toY+30);
- CGPathAddLineToPoint(self.linePath, NULL, toX+30, toY+30);
- CGPathAddLineToPoint(self.linePath, NULL, toX2+20, toY2+20);
- self.lineShape.path = self.linePath;
- CGPathRelease(self.linePath);
- self.lineShape.zPosition = -1;
- [self.view.layer addSublayer:self.lineShape];*/
- }
- }
- -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
- //self.posXcirkels = [[NSMutableArray alloc] init];
- //self.posYcirkels = [[NSMutableArray alloc] init];
- for (int i = 0; i<[self.cirkleArray count]; i++) {
- Cirkel *itObject = [self.cirkleArray objectAtIndex:i];
- //UIView *itNaam = [itObject cirkelNaam];
- float posYcirkelAanpassen = [itObject posYcirkel];
- float posXcirkelAanpassen = [itObject posXcirkel];
- NSNumber *numX = [NSNumber numberWithFloat:posXcirkelAanpassen];
- [self.posXcirkels addObject:numX];
- NSNumber *numY = [NSNumber numberWithFloat:posYcirkelAanpassen];
- [self.posYcirkels addObject:numY];
- if(posYcirkelAanpassen > -50 && posXcirkelAanpassen > -50 && posYcirkelAanpassen < self.xScherm+50 && posXcirkelAanpassen < self.xScherm+50){
- float schuineZijde = sqrt(((posYcirkelAanpassen-self.posX)*(posYcirkelAanpassen-self.posX)+(posYcirkelAanpassen-self.posY)*(posYcirkelAanpassen-self.posY))); //pythagoras!!
- float ratioC = (self.yScherm-schuineZijde)/50;
- [self.ratio addObject:[NSNumber numberWithFloat:ratioC]];
- }
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement