GSComponent Class Reference
Inherits from | GSElement : NSObject |
Tasks
-
componentName
property -
component
property -
transformStruct
property -
anchor
property -
pieceSettings
property -
– bounds
-
– bezierPath
-
– openBezierPath
-
– componentLayer
-
– getScaleX:scaleY:rotation:
-
– setScaleX:scaleY:rotation:
-
– decompose
-
– intersects:
-
– makeFirst
-
userData
property -
– setUserData:forKey:
-
– removeUserDataForKey:
Properties
anchor
If more than one anchor/_anchor pair would match, this property can be used to set the anchor to use for automatic alignment
@property (copy, nonatomic) NSString *anchor
Discussion
This can be set from the anchor button in the component info box in the UI
component
The base glyph
@property (unsafe_unretained, readonly) GSGlyph *component
Discussion
This is readonly. To set the base glyph use componentName: newBaseGlyph.name.
See Also
componentName
components are referenced by the glyph name.
@property (strong, nonatomic) NSString *componentName
Discussion
If you set the componentName the component value is set and this is used during runtime. So you can change the glyph name of the base glyph during runtime.
pieceSettings
The instance settings do Smart Components.
@property (strong, nonatomic) GSNotifyingDictionary *pieceSettings
Discussion
It is a dictionary containing the parameter names as keys and the interpolation position as value.
{
Height = 70;
Width = 70;
}
See Also
GSGlyph.partsSettings
transformStruct
The transformation of the component.
@property (assign, nonatomic) NSAffineTransformStruct transformStruct
Discussion
The values of the struct are: {m11, m12, m21, m22, tX, tY} this is equivalent to the glif attributes {xScale, xyScale, yxScale, yScale, xOffset, yOffset} in the same order. The initial value is {1,0,0,1,0,0}.
userData
Place for plugins to store custom data.
@property (strong, nonatomic, nullable) NSMutableDictionary *userData
Discussion
Here it is possible to store something. Please use a unique key. The objects should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).
Instance Methods
bezierPath
The bezierPath of the component. It is already transformed.
- (NSBezierPath *_Nullable)bezierPath
componentLayer
The Layer that the component is linked to.
- (GSLayer *)componentLayer
Return Value
the Layer that represents the component.
Discussion
The is usually just the layer from the components glyph but might be the computed result of a smart component.
decompose
Decomposes the component to the containing Layer
- (void)decompose
Discussion
It need to parent property set correctly. It calls [_parent decomposeComponent:self]
.
getScaleX:scaleY:rotation:
Retunes on reference the scale and rotation of the component
- (void)getScaleX:(CGFloat *)sX scaleY:(CGFloat *)sY rotation:(CGFloat *)R
Parameters
- sX
On return, the horizontal scale
- sY
On return, the vertical scale
- R
On return, the rotation
Discussion
This will take apart the transformStruct.
This might not work correctly if you have applied a skew transform.
intersects:
If the component overlaps with the OtherComponent
- (BOOL)intersects:(GSComponent *)OtherComponent
Parameters
- OtherComponent
The OtherComponent to test overlap.
Return Value
Returns YES if both components do overlap, otherwise NO.
makeFirst
It makes the component the first in the containing Layer
- (void)makeFirst
Discussion
It need to parent property set correctly. It calls [_parent makeFirstComponent:self]
.
openBezierPath
The bezierPath of open paths of the component. It is already transformed.
- (NSBezierPath *_Nullable)openBezierPath
removeUserDataForKey:
Removed the object with this key.
- (void)removeUserDataForKey:(NSString *)key
Parameters
- key
The to remove
setScaleX:scaleY:rotation:
Sets the transformation.
- (void)setScaleX:(CGFloat)sX scaleY:(CGFloat)sY rotation:(CGFloat)R
Parameters
- sX
the horizontal scale
- sY
the vertical scale
- R
the rotation
setUserData:forKey:
Adds something to the fonts userData.
- (void)setUserData:(id)value forKey:(NSString *)key
Parameters
- value
The object should be able to serialize to a plist. If they are not, they should return all infos to store in description (as String).
- key
Please use an uniqe key that gives some indecation who put it there (e.g. prefix it with your name or project).
Discussion
This also triggers undo/document dirty state.