# Quick Preview

> CoreBox provides built-in instant preview capabilities that automatically recognize and display preview cards as you type in the search box.

## Feature List

Tuff includes 9 preview abilities covering calculations, conversions, time, colors, and more.

**Advanced Expression Calculator**

**Examples**: `sqrt(16)`, `sin(45)`, `log(100)`, `2^10`, `10% of 200`

Supported functions:
- **Trigonometric**: `sin`, `cos`, `tan`
- **Logarithmic**: `log`, `ln`
- **Mathematical**: `sqrt`, `abs`, `round`, `ceil`, `floor`, `pow`, `exp`
- **Constants**: `pi`, `e`
- **Percentage syntax**: `X% of Y` (calculates X% of Y), `X + Y%` (increases X by Y%)

Evaluated by a deterministic allowlisted parser — only the operators, functions and constants listed above are accepted, and no generic code evaluation is involved.

---

**Basic Expression Calculator**

**Examples**: `1+2`, `100*3`, `(10+5)/3`, `50%`

Quick calculation for pure numbers and basic operators (`+`, `-`, `*`, `/`, `%`, `()`). Lightweight mode without loading math libraries.

---

**Unit Conversion**

**Examples**: `10km to mi`, `100kg to lb`, `32f to c`, `1gb to mb`

Supported unit types:

| Category | Unit Examples |
|----------|---------------|
| **Length** | mm, cm, m, km, in, ft, mi |
| **Mass** | mg, g, kg, lb, oz, t |
| **Volume** | ml, l, gal, cup |
| **Data** | bit, byte, kb, mb, gb, kib, mib, gib |
| **Temperature** | c(℃), f, k |

Also supports Chinese unit names like mi, qian ke, gong jin.

---

**Scientific Constants**

**Examples**: `gravity`, `speed of light`, `planck constant`, `π`

Built-in physics and mathematics constants library including:
- Speed of light, gravitational acceleration
- Planck constant, Boltzmann constant
- Avogadro's number
- Pi (π)

Displays constant value, unit, source (CODATA 2018), and aliases.

---

**Color Parser**

**Examples**: `#ff5500`, `rgb(255, 100, 50)`, `hsl(30, 100%, 50%)`, `red`, `blue`

Supported color formats:
- **HEX**: `#RGB`, `#RRGGBB`, `#RRGGBBAA`
- **RGB/RGBA**: `rgb(r, g, b)`, `rgba(r, g, b, a)`
- **HSL/HSLA**: `hsl(h, s%, l%)`, `hsla(h, s%, l%, a)`
- **Named colors**: `red`, `blue`, `green`, `orange`, etc.

Preview card shows color swatch and automatically converts between HEX, RGB, and HSL formats.

---

**Time Calculator**

**Examples**:

| Scenario | Input Example |
|----------|---------------|
| **Time offset** | `now + 2h`, `now - 30min` |
| **Natural language** | `tomorrow`, `yesterday`, `3 days ago`, `in 2 weeks` |
| **Duration conversion** | `90min`, `2.5h`, `180s` |
| **Date difference** | `2024-12-31`, `2024-01-01 - now` |

Supports multiple time units: seconds (s), minutes (m/min), hours (h/hr), days (d/day), weeks (w/week).

---

**Currency Conversion**

**Examples**: `100 usd to cny`, `$50 to eur`, `¥1000 to jpy`

Supported currencies:

| Currency | Code | Symbol |
|----------|------|--------|
| US Dollar | USD | $ |
| Chinese Yuan | CNY | ¥ / ￥ |
| Euro | EUR | € |
| Japanese Yen | JPY | - |
| Hong Kong Dollar | HKD | - |
| British Pound | GBP | £ |
| Korean Won | KRW | ₩ |
| Bitcoin | BTC | ₿ |
| Ethereum | ETH | Ξ |

> **Note**: Exchange rates are built-in reference values, not real-time data.

---

**Percentage Calculator**

**Examples**:

| Scenario | Input | Result |
|----------|-------|--------|
| Increase | `100 + 20%` | 120 |
| Decrease | `100 - 15%` | 85 |
| Calculate | `20% of 500` | 100 |
| Percentage math | `30% + 20%` | 50% |

---

**Text Statistics**

**Examples**: `len "Hello World"`, `count "some text"`, `words "hello"`

Trigger keywords: `words`, `chars`, `len`, `length`, `count`

Statistics include:
- Character count
- Word count (split by whitespace)
- Chinese character count
- ASCII character count
- Line count

---

## Tips

1. **Direct input**: No prefix needed, CoreBox automatically recognizes content type
2. **Copy result**: Click on preview card to quickly copy the result
3. **Multiple results**: Some abilities (like unit conversion) show multiple common conversions
4. **Real-time**: All previews are calculated in real-time as you type
