mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-16 05:35:27 -04:00
Merge branch 'tempv0.121.2'
This commit is contained in:
commit
97dbc1ea12
BIN
assets/images/examples/landscape-exif-orientation-5.jpg
Normal file
BIN
assets/images/examples/landscape-exif-orientation-5.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
52
content/en/functions/images/AutoOrient.md
Normal file
52
content/en/functions/images/AutoOrient.md
Normal file
@ -0,0 +1,52 @@
|
||||
---
|
||||
title: images.AutoOrient
|
||||
description: Returns an image filter that rotates and flips an image as needed per its EXIF orientation tag.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/images/Filter
|
||||
- methods/resource/Filter
|
||||
returnType: images.filter
|
||||
signatures: [images.AutoOrient]
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.122.0 >}}
|
||||
|
||||
## Usage
|
||||
|
||||
Create the filter:
|
||||
|
||||
```go-html-template
|
||||
{{ $filter := images.AutoOrient }}
|
||||
```
|
||||
|
||||
{{% include "functions/images/_common/apply-image-filter.md" %}}
|
||||
|
||||
{{% note %}}
|
||||
When using with other filters, specify `images.AutoOrient` first.
|
||||
{{% /note %}}
|
||||
|
||||
```go-html-template
|
||||
{{ $filters := slice
|
||||
images.AutoOrient
|
||||
(images.Process "resize 200x")
|
||||
}}
|
||||
{{ with resources.Get "images/original.jpg" }}
|
||||
{{ with images.Filter $filters . }}
|
||||
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
{{< img
|
||||
src="images/examples/landscape-exif-orientation-5.jpg"
|
||||
alt="Zion National Park"
|
||||
filter="AutoOrient"
|
||||
filterArgs=""
|
||||
example=true
|
||||
>}}
|
44
content/en/functions/math/Rand.md
Normal file
44
content/en/functions/math/Rand.md
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
title: math.Rand
|
||||
description: Returns a pseudo-random number in the half-open interval [0.0, 1.0).
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related: []
|
||||
returnType: float64
|
||||
signatures: [math.Rand]
|
||||
---
|
||||
|
||||
The `math.Rand` function returns a pseudo-random number in the [half-open interval] [0.0, 1.0).
|
||||
|
||||
```go-html-template
|
||||
{{ math.Rand }} → 0.6312770459590062
|
||||
```
|
||||
|
||||
To generate a random integer in the [closed interval] [0, 5]:
|
||||
|
||||
```go-html-template
|
||||
{{ math.Rand | mul 6 | math.Floor }}
|
||||
```
|
||||
|
||||
To generate a random integer in the closed interval [1, 6]:
|
||||
|
||||
```go-html-template
|
||||
{{ math.Rand | mul 6 | math.Ceil }}
|
||||
```
|
||||
|
||||
To generate a random float, with one digit after the decimal point, in the closed interval [0, 4.9]:
|
||||
|
||||
```go-html-template
|
||||
{{ div (math.Rand | mul 50 | math.Floor) 10 }}
|
||||
```
|
||||
|
||||
To generate a random float, with one digit after the decimal point, in the closed interval [0.1, 5.0]:
|
||||
|
||||
```go-html-template
|
||||
{{ div (math.Rand | mul 50 | math.Ceil) 10 }}
|
||||
```
|
||||
|
||||
[closed interval]: /getting-started/glossary/#interval
|
||||
[half-open interval]: /getting-started/glossary/#interval
|
Loading…
x
Reference in New Issue
Block a user