JSignage:Frame decoration attributes
From SpinetiX Support Wiki
Contents
Description
Frame decoration attributes apply to all types of layers. They are optional, but when present, they can:
- Specify a solid or semi-transparent background to the layer.
- Draw a frame at the layer's borders.
- Alter the shape of the layer's corners.
- Add some decoration elements around the layer, such as shadows.
- Set some padding between the layer's borders and its content.
The frame decoration attributes are specified in the frame
attribute of the layer, which must be an object containing the one or more of the attributes specified below. For instance: { screenColor: 'white', shape: 'round' }
frame
attribute cannot be modified using $.attr()
- instead, the layer needs to be recreated.Attributes definition
Common
-
screenColor
- Color of the screen area around a media frame. It provides the default value whenever a decoration effect needs to match the screen color. Default:
'currentColor'
.
- Color of the screen area around a media frame. It provides the default value whenever a decoration effect needs to match the screen color. Default:
Shape of the corners
-
shape
- One of
'square'
,'round'
or'snip'
. Defines the shape of the corners of the frame or media. Default:'square'
.
- One of
-
rx
- Horizontal size of the corners when the shape is not square, i.e. radius for round corners. The size is expressed as an absolute number of pixels or as a percentage of the smaller of the width or height of the layer. Default:
'20%'
.
- Horizontal size of the corners when the shape is not square, i.e. radius for round corners. The size is expressed as an absolute number of pixels or as a percentage of the smaller of the width or height of the layer. Default:
-
ry
- Vertical size of the corners when the shape is not square. By default it is equal to
rx
. If different the round corners are in fact elliptical.
- Vertical size of the corners when the shape is not square. By default it is equal to
-
corners
- Array of corners whose shape is modified. Default:
.[ 'topLeft', 'topRight', 'bottomRight', 'bottomLeft' ]
. Note that elements if the array must always appear in this order.
- Array of corners whose shape is modified. Default:
-
clip
- Control whether the layer's content should be clipped at the corners. Clipping is implemented by hiding the part of the content that is outside of the frame's shape behind the
screenColor
opaque color. The valed values are'none'
,'auto'
or'force'
. When set to'auto'
, clipping will only be applied when the layer is a media layer and some of the content lies outside of the shape. Default value:'auto'
.
- Control whether the layer's content should be clipped at the corners. Clipping is implemented by hiding the part of the content that is outside of the frame's shape behind the
Background color
Layers are transparent by default. An opaque background color can be specified instead.
-
backColor
- Color of the background. Default:
'none'
.
- Color of the background. Default:
-
backOpacity
- Opacity of the background. Default:
'100%'
.
- Opacity of the background. Default:
-
uiStyle
- If not null, must be one of the three UI styles:
'manzana'
,'round'
or'square'
. Default:null
.
- If not null, must be one of the three UI styles:
Drawing a frame
Note that the frame is contained entirely inside the area assigned to the layer, thus reducing the area for its content. This is done in a way that does not modify the aspect ratio of the area, but rather clips some of the content at the border if needed to maintain aspect ratio.
-
frameColor
- Color of the frame. If equal to
'none'
, no frame is drawn. Default:'none'
.
- Color of the frame. If equal to
-
frameSize
- Size of the frame as an absolute number of pixels or as a percentage of the smaller of the layer width or height. Default:
'6%'
.
- Size of the frame as an absolute number of pixels or as a percentage of the smaller of the layer width or height. Default:
Content padding
-
padding
- Size of padding for all borders if there only one number, or array of padding sizes for the top, right, bottom and left border in that order, separated by spaces. Each padding size is either an absolute number of pixels or a percentage of the smaller of the layer width or height. Default: '0'.
Soft edges
Soft edges blends the content at its interface. This allows a smoother color transition, and gives a blurred appearance to the borders.
-
softEdge
- When true a mask is drawn on top the media to blend the borders with the background color. Default:
false
.
- When true a mask is drawn on top the media to blend the borders with the background color. Default:
-
softEdgeSize
- Size of the soft edges gradient as an absolute number of pixel or as a percentage of the smaller of the layer width or height. Default:
'6%'
.
- Size of the soft edges gradient as an absolute number of pixel or as a percentage of the smaller of the layer width or height. Default:
-
softEdgeColor
- Color used to soften the borders. Default: frameColor, if the decoration also specifies a frame, otherwise screenColor.
Shadows
-
shadow
- When true a semi-transparent shadow is drawn around the layer borders. The shadow is drawn outside of the area assigned to the layer and does not impact the size of its content. Default:
false
.
- When true a semi-transparent shadow is drawn around the layer borders. The shadow is drawn outside of the area assigned to the layer and does not impact the size of its content. Default:
-
shadowSize
- Size of the drop shadow as an absolute number of pixels or as a percentage of the smaller of the layer width or height. Default:
'3%'
.
- Size of the drop shadow as an absolute number of pixels or as a percentage of the smaller of the layer width or height. Default:
-
shadowColor
- Color of the shadow. Default:
'#A0A0A0'
- Color of the shadow. Default:
Special effects
-
specialFX
The following effects are currently supported:-
reflection
a mirror reflection of the layer at the bottom -
rotate
a pseudo-3d paper sheet effect around the layer
-
Notes:
- In order to apply reflection the screen background behind the media must be of a constant color and
reflectionColor
or by defaultscreenColor
must be set to that color. - Caution: Applying specials effect to a video or animation media causes a severe performance penalty and requires testing the resulting project for adequate performance.
Examples
Rounded corners
Add a rounded corner to an image on a white background.
$(function(){
$.media({ left: '10%', top: '20%', width: '640', height: '480', href: 'image_4_3.jpg',
frame: { screenColor: 'white', shape: 'round' }
}).addTo('svg');
});
Notes:
- The background must be of an uniform color (and equal to screenColor ) in order to use the round frame. This example is designed to be displayed on an uniform white background.
- The aspect ratio of the file must match the one of the media for the rounded corner to be visible.
- The same notes applies to the snip type of corner
Partial snip corners
Cut the top right and bottom left corner of the image.
$(function(){
$.media({ left: '35%', top: '25%', width: 400, height: 300, href: 'image_4_3.jpg',
frame: { screenColor: 'white', shape: 'snip' , corners: [ 'topRight', 'bottomLeft' ]}
}).addTo('svg');
});
-
corners: [ 'topRight', 'bottomLeft' ]
controls which corner are modified by the decoration.
Soft edge around an image
Blur the edge of the image to make it fade into the background.
$(function(){
$.media({ left: '10%', top: '10%', width: '80%', height: '80%' , href: 'image_16_9.jpg',
frame: { softEdge : true, screenColor : 'white', softEdgeSize :'10%' }
}).addTo('svg');
});
- The aspect ratio of the media viewbox must match the one of the image file in order for the soft edges to be applied correctly.
Shadow with a frame
Add a white frame and a drop shadow around the image.
$(function(){
$.media({ left: 120, top: 30, width: 400, height: 300, href: 'image_4_3.jpg',
frame: { frameColor: 'white', frameSize: '5%', shadow: true }
}).addTo('svg');
});
- Adding a frame around the image increases the effect of the shadow.
- Shadows are looking better on a white or bright colored background.