Login About Gallery
Text to PNG
COMMENT
This shortcut is a function to convert text to PNG with the font, size, color and dimensions indicated by the user — @atnbueno (2020-09-18) - The shortcut expects to receive a dictionary like the one inside the "if" as input - Without input, the “if” dictionary is used (allowing the user to edit it) and the resulting image is displayed at the end - The text can be left empty if you only want to obtain a solid color image - Examples of valid colors: red, #0F0, #FF00FF, rgb(255, 0, 255), #FF7F007F, rgba(255, 127, 0, 0.5) - See https://developer.apple.com/fonts/system-fonts/ for typefaces available in iOS RoutineHubUpdate Current Version: "1.1.1" RoutineHub ID: "6552" RoutineHubUpdate
SCRIPTING
If
Shortcut Input
does not have any value
DICTIONARY
<inline variable>
🍊 Tangerine
Ask Each Time
<inline variable>
<inline variable>
<inline variable>
<inline variable>
<inline variable>
<inline variable>
<inline variable>
<inline variable>
<inline variable>
<inline variable>
Otherwise
SCRIPTING
Get dictionary from
Shortcut Input
End If
TEXT
// Input parameters let input = JSON.parse(`
Resultado de la acción Si
`); // Generate image from input with(canvas = document.createElement("canvas")) with(context = getContext("2d")) { font = input.font; with(measureText(input.text)) with(input) { // Determine position and size of the text (min. canvas size = text size) width = Math.max(width, actualBoundingBoxRight + actualBoundingBoxLeft + 2); height = Math.max(height, actualBoundingBoxAscent + actualBoundingBoxDescent); let x = (width - actualBoundingBoxRight + actualBoundingBoxLeft) / 2; let y = (height + actualBoundingBoxAscent - 1) / 2; // Set canvas size canvas.width = width; canvas.height = height; // If canvas isn't high enough, enlarge canvas and re-center vertically if (y - actualBoundingBoxAscent - actualBoundingBoxDescent < 0) { canvas.height += actualBoundingBoxDescent; y += y - actualBoundingBoxAscent; } // Paint background fillStyle = bgcolor; fillRect(0, 0, canvas.width, canvas.height); // Paint text context.font = font; // yep, again fillStyle = color; fillText(text, x, y); } // Show base64 encoding of the generated image document.write(toDataURL().split(',')[1]); }
URL
data:text/html;charset=utf-8,<script>
JavaScript
</script>
SCRIPTING
Get file of type
com.apple.webarchive
from
URL
SCRIPTING
Decode
Archivo del tipo
with base64
DOCUMENTS
Replace
#
with
World
in
color
-on-
height
-
bgcolor
x
width
.png
Case Sensitive
Regular Expression
SCRIPTING
If
Shortcut Input
does not have any value
DOCUMENTS
Show
Ítem renombrado
in Quick Look
End If

Showcuts

Magic Vars

Screenshot

Submitted Anonymously 8 days ago

Visit iCloud (iOS)

Copy iCloud Link

Scan QR Code

0