# 2D Shadow Effect

#### <a class="anchor" id="bkmrk--5"></a>Description

This chapter briefly describes how to use the 2D shadow effect.

<div class="contents" id="bkmrk-ensure-that-this-eff"><div class="contents"><div class="textblock"><dl class="note"><dt></dt><dd><p class="callout info">Ensure that this effect is supported by the device platform in use.</p>

</dd></dl></div></div></div>#### **2D Configure a Shadow Effect** 

##### <a class="anchor" id="bkmrk--7"></a>Shadow Effect

By using [Candera::ShadowBitmapBrushBlend](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_shadow_bitmap_brush_blend.html "Output a shadowed or glowing bitmap image, both shadow/glow and image alpha blended."), a colored shadow can be applied to a bitmap.

Following properties of the shadow can be configured:

<div class="contents" id="bkmrk-color-%28including-alp"><div class="contents"><div class="textblock">- Color (including alpha value)
- Scale (the shadow size related to the bitmap)
- Position Offset (related to the bitmap)

</div></div></div>Following is an example of a grey colored shadow, with a scale of 70% and an offset of 80/80 related to the bitmap:

<div drawio-diagram="2657"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-4-1677466312.png" alt=""/></div>

<div class="contents" id="bkmrk--1"><div class="contents"><div class="textblock"><div class="image">  
</div></div></div></div>Refer to <span style="color: rgb(230, 126, 35);">[SceneComposer User Manual](https://doc316en.candera.eu/books/scene-design/page/effects)</span> about how to configure a ShadowBitmapBrushBlend effect in a 2D scene.

#### **Modify 2D Shadow Effect Properties** 

##### <a class="anchor" id="bkmrk--9"></a>Access Shadow Effect

To modify the shadow effect properties, first the shadow effect needs to be retrieved from its render node:

```
    // Get and cast first effect of render node
    Effect2D* effect2D = renderNode->GetEffect(0);
    ShadowBitmapBrushBlend* shadow = 0;
    if (effect2D != 0){
        shadow = (ShadowBitmapBrushBlend*) effect2D;
    }
    // End Get and cast first effect of render node
```

##### <a class="anchor" id="bkmrk--10"></a>Set Shadow Color

Specify a color with a red, a blue, a green and an alpha component and apply the color to the Shadow Effect.

Example:

```
Color::Data c;
c.alpha = 0.5f;
c.blue = 0.0f;
c.green = 0.0f;
c.red = 1.0f;
shadow->ShadowColor().Set(c);
```

##### <a class="anchor" id="bkmrk--11"></a>Set Shadow Scale

For the shadow's scale you need the scale X and Y value. Add the two values to a Vector2 and set the shadow's scale.

Example:

```
Float shadowScaleX = 0.7f;
Float shadowScaleY = 0.7f;
shadow->ShadowScale().Set(Vector2(shadowScaleX, shadowScaleY));
```

##### <a class="anchor" id="bkmrk--12"></a>Set Shadow Position Offset

It is possible to change the position of the shadow by changing its offset to the node. Therefore you need a Vector2 with the X and Y offset values again.

Example:

```
Float shadowPosOffX = 5.0f;
Float shadowPosOffY = 7.0f;
shadow->ShadowPositionOffset().Set(Vector2(shadowPosOffX, shadowPosOffY));
```