# Changing stroke color dynamically

**URL:** <https://forum.kirupa.com/t/changing-stroke-color-dynamically/324112>\
**Category:** programming\
**Created:** [August 3, 2011, 12:00am UTC](https://forum.kirupa.com/t/changing-stroke-color-dynamically/324112 "2011-08-03T00:00:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sajib\_bd](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@sajib\_bd](https://forum.kirupa.com/u/sajib_bd)\
**Post date:** [August 3, 2011, 12:00am UTC](https://forum.kirupa.com/t/changing-stroke-color-dynamically/324112/1 "2011-08-03T00:00:21Z")

</div>

Hi, I am using stylus input to draw lines in a canvas. I want to change the color of the stroke with the pen pressure. so I used:

DrawingAttributes dattribute = new DrawingAttributes();  
inkcan.EditingMode = InkCanvasEditingMode.Ink;

if (stylusInput.pressureFactor \< 0.5)  
dattribute.Color = Colors.Red;  
else  
dattribute.Color = Colors.Blue;

dattribute.IgnorePressure = true;  
inkcan.DefaultDrawingAttributes = dattribute;

but I have found that the color changes only when I lift off the pen from tablet. I am not sure how to fix that problem.

Any help would be greatly appreciated.
