-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSCScale.m
More file actions
37 lines (26 loc) · 721 Bytes
/
SCScale.m
File metadata and controls
37 lines (26 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// SCScale.m
// Alarm-Clock
//
// Created by Robert Palmer on 30.01.10.
// Copyright 2010 Robert. All rights reserved.
//
#import "SCScale.h"
@implementation SCScale
@synthesize fromRangeStart, fromRangeEnd;
@synthesize toRangeStart, toRangeEnd;
- (void)setScaleFromRangeStarting:(float)x1 ending:(float)x2 {
self.fromRangeStart = x1;
self.fromRangeEnd = x2;
}
- (void)setScaleToRangeStarting:(float)x1 ending:(float)x2 {
self.toRangeStart = x1;
self.toRangeEnd = x2;
}
- (float)scaleValue: (float)value {
float fromLength = fromRangeEnd - fromRangeStart;
float p = (value - fromRangeStart) / fromLength;
float toLength = toRangeEnd - toRangeStart;
return toRangeStart + (toLength * p);
}
@end