-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAQTColorMap.m
65 lines (58 loc) · 954 Bytes
/
AQTColorMap.m
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// AQTColorMap.m
// AquaTerm
//
// Created by Bob Savage on Mon Jan 28 2002.
// Copyright (c) 2002-2003 Aquaterm. All rights reserved.
//
#import "AQTColorMap.h"
@implementation AQTColorMap
-(id)init
{
return [self initWithColormapSize:1]; // Black
}
-(id)initWithColormapSize:(int32_t)mapsize
{
if (self = [super init])
{
size = (mapsize < 1)?1:mapsize;
colormap = malloc(size*sizeof(AQTColor));
if(!colormap)
{
[self autorelease];
return nil;
}
}
return self;
}
-(void)dealloc
{
if (colormap)
{
free(colormap);
}
[super dealloc];
}
-(int32_t)size
{
return size;
}
-(void)setColor:(AQTColor)newColor forIndex:(int32_t)index
{
if (index >= 0 && index < size)
{
colormap[index] = newColor;
}
}
-(AQTColor)colorForIndex:(int32_t)index
{
if (index < 0 || index >= size)
{
return colormap[0];
}
else
{
return colormap[index];
}
}
@end