Skip to content

Instantly share code, notes, and snippets.

@arunjeetsingh
Last active July 27, 2020 23:13
Show Gist options
  • Save arunjeetsingh/bd33b73c63c94f251f4c3c3b40d0929c to your computer and use it in GitHub Desktop.
Save arunjeetsingh/bd33b73c63c94f251f4c3c3b40d0929c to your computer and use it in GitHub Desktop.
An APL document with a gradient background and optional picture. More about APL here https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/understand-apl.html.
{
"document": {
"type": "APL",
"version": "1.4",
"import": [
{
"name": "alexa-layouts",
"version": "1.2.0"
}
],
"graphics": {
"gradientBackground": {
"type": "AVG",
"version": "1.1",
"height": 100,
"width": 100,
"scaleTypeHeight": "grow",
"parameters": [
{
"name": "gradientFill",
"type": "gradient"
}
],
"items": [
{
"type": "path",
"pathData": "M0,0 L${width},0 L${width},${height} L0,${height}",
"fill": "${gradientFill}"
}
]
}
},
"mainTemplate": {
"parameters": [
"backgroundData"
],
"items": [
{
"type": "Container",
"width": "100%",
"height": "100%",
"items": [
{
"when": "${backgroundData.pictureSource}",
"type": "AlexaBackground",
"backgroundImageSource": "${backgroundData.pictureSource}"
},
{
"type": "VectorGraphic",
"source": "gradientBackground",
"width": "100%",
"height": "100%",
"scale": "fill",
"gradientFill": "${backgroundData.pictureSource ? backgroundData.pictureOverlay : backgroundData.noPictureOverlay}"
},
{
"type": "Container",
"position": "absolute",
"width": "100%",
"height": "100%",
"alignItems": "center",
"justifyContent": "center",
"items": [
{
"type": "AlexaHeader",
"headerTitle": "${backgroundData.headlineText}",
"headerAttributionPrimacy": false
}
]
}
]
}
]
},
"layouts": {}
},
"datasources": {
"backgroundData": {
"headlineText": "Red/Black gradient",
"pictureSource": "",
"pictureOverlay": {
"type": "linear",
"colorRange": [
"rgb(255,0,0,0.2)",
"rgb(0,0,0,1.0)"
],
"x1": 0,
"x2": 1,
"y1": 0,
"y2": 1
},
"noPictureOverlay": {
"type": "linear",
"colorRange": [
"rgb(125,0,0,1)",
"rgb(10,10,10,1)"
],
"x1": 0,
"x2": 1,
"y1": 0,
"y2": 1
}
}
},
"sources": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment