---
description: Using the sourceText to show Values you wouldn't normally be able to display.
---

# Display Value

## TIME

#### -Countdown Timer

<pre class="language-javascript"><code class="lang-javascript">Slider = effect("Slider Control")("Slider");

ms = Math.floor(slider/1000);
seconds = Math.floor(slider%60);
minutes = Math.floor(slider/60);
minutes = Math.floor(slider%60)
hours = Math.floor (slider/3600)


function addZero(n) {
if(n &#x3C; 10) {
return '0' + n
} else {
return n;
}
}

if (slider > 0) {
addZero(hours) + ':' + addZero(minutes) + ':' + addZero(seconds) + ':' + (ms)
} else {
'00:00'
<strong>}
</strong></code></pre>

{% hint style="info" %}
Slider Controls Value and the expression will output digital clock format
{% endhint %}

#### -Current Comp Time

```javascript
timeToTimecode(t = time + thisComp.displayStartTime,
timecodeBase = 30,
isDuration = false);

```

{% hint style="info" %}
Display current time of comp.
{% endhint %}

#### -Current Time

```javascript


var date = new Date(Date(0));

var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();

hours + ':' + minutes + ':' + seconds;
```

{% hint style="info" %}
Displays the current clock time of the machine it is running on&#x20;
{% endhint %}

#### -Current Frame&#x20;

```javascript
timeToFrames(time,25);
```

{% hint style="info" %}
Displays Current Frame, change "25" to match your frame rate
{% endhint %}

#### -Display Timecode, Frames & FPS

```javascript
// Ensure the timeToTimecode function is called with the correct parameters
var currentTime = time;
var displayStartTime = thisComp.displayStartTime;
var frameRate = thisComp.frameRate;
var frameDuration = thisComp.frameDuration;

// Convert current time to timecode
var timeCode = timeToTimecode(currentTime + displayStartTime, frameRate, false);

// Calculate the current frame number
var frameNum = (currentTime - displayStartTime) / frameDuration;

// Check if the checkboxes exist, if not create default values
var hideTimeCode = false;
var hideFrames = false;
var hideFPS = false;

try {
    hideTimeCode = (effect("Hide Time Code")("Checkbox") > 0);
} catch (e) {
    hideTimeCode = false;
}

try {
    hideFrames = (effect("Hide Frames")("Checkbox") > 0);
} catch (e) {
    hideFrames = false;
}

try {
    hideFPS = (effect("Hide FPS")("Checkbox") > 0);
} catch (e) {
    hideFPS = false;
}

// Build the display string based on checkbox states
var displayString = "";

if (!hideTimeCode) {
    displayString += timeCode + " | ";
}

if (!hideFrames) {
    displayString += "Frame: " + Math.round(frameNum) + " | ";
}

if (!hideFPS) {
    displayString += "FPS: " + frameRate.toFixed(2);
}

// Return the final display string
displayString;

```

{% hint style="info" %}
This After Effects expression displays the current timecode, frame number, and frame rate. It includes optional checkboxes to hide each element. It calculates timecode using`timeToTimecode` and ensures compatibility even if checkboxes are absent.\
`Updated: 17/07/24`
{% endhint %}

## COLOR

#### -Display RGB Code

```javascript
//Print RGB Value
theColor = thisComp.layer("Color Style").effect("Color 1")("Color");
r = Math.round(theColor[0]*255)
g = Math.round(theColor[1]*255)
b = Math.round(theColor[2]*255)
"r,"+r +" g,"+g+" b,"+b

```

{% hint style="info" %}
Displays RGB Code in Source Text
{% endhint %}

#### -Display Hex Code

```javascript
//Print Hex Value
theColor = thisComp.layer("Color Style").effect("Color 1")("Color");
r = Math.round(theColor[0]*255).toString(16)
g = Math.round(theColor[1]*255).toString(16)
b = Math.round(theColor[2]*255).toString(16)
"#"+r+g+b;
```

{% hint style="info" %}
Displays Hex Code in Source Text
{% endhint %}

### Refrence

#### -Display Nearest Marker Comment

```javascript
m = thisComp.layer("Marker Layer").marker;
txt = "";
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0) txt = m.key(n).comment;
}
txt

```

{% hint style="info" %}
Displays text of nearest Marker
{% endhint %}



####
