API  0.9.10
CPShadow.j
Go to the documentation of this file.
1 /*
2  * CPShadow.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
30 @implementation CPShadow : CPObject
31 {
32  CGSize _offset;
33  float _blurRadius;
34  CPColor _color;
35 }
36 
44 + (id)shadowWithOffset:(CGSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
45 {
46  return [[CPShadow alloc] _initWithOffset:anOffset blurRadius:aBlurRadius color:aColor];
47 }
48 
49 /* @ignore */
50 - (id)_initWithOffset:(CGSize)anOffset blurRadius:(float)aBlurRadius color:(CPColor)aColor
51 {
52  self = [super init];
53 
54  if (self)
55  {
56  _offset = anOffset;
57  _blurRadius = aBlurRadius;
58  _color = aColor;
59  }
60 
61  return self;
62 }
63 
64 - (void)set
65 {
67 
68  CGContextSetShadowWithColor(context, _offset, _blurRadius, _color);
69 }
70 
75 {
76  return [_color cssString] + " " + ROUND(_offset.width) + @"px " + ROUND(_offset.height) + @"px " + ROUND(_blurRadius) + @"px";
77 }
78 
79 @end
80 
82 
86 - (CGSize)shadowOffset
87 {
88  return _offset;
89 }
90 
94 - (void)setShadowOffset:(CGSize)aValue
95 {
96  _offset = aValue;
97 }
98 
103 {
104  return _blurRadius;
105 }
106 
110 - (void)setShadowBlurRadius:(float)aValue
111 {
112  _blurRadius = aValue;
113 }
114 
119 {
120  return _color;
121 }
122 
126 - (void)setShadowColor:(CPColor)aValue
127 {
128  _color = aValue;
129 }
130 
131 @end
function CGContextSetShadowWithColor(aContext, aSize, aBlur, aColor)
Definition: CGContext.j:504
CPGraphicsContext currentContext()
CPString cssString()
Definition: CPShadow.j:74
void set()
Definition: CPShadow.j:64
An immutable string (collection of characters).
Definition: CPString.h:2
id init()
Definition: CPObject.j:145
id alloc()
Definition: CPObject.j:130