Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active April 5, 2018 19:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/357b022f298ff90d821477324e9c8cf4 to your computer and use it in GitHub Desktop.
Save toomasv/357b022f298ff90d821477324e9c8cf4 to your computer and use it in GitHub Desktop.
Study of text mirroring
Red [
Author: "Toomas Vooglaid"
Date: 2018-04-05
Purpose: "Study of text mirroring"
File: %mirror.red
]
comment {
; === Some tries ===
; = Simple horizontal mirror - Leonardo script
view [box 200x30 draw [transform 0x0 0 -1 1 200x0 text 0x0 "Leonardo da Vinci wrote Mirrored text"]]
; = Horizontally reversed vertically mirrored
txt: reverse copy "Leonardo da Vinci wrote Mirrored text -- you can too!"
view compose/deep [box 290x30 draw [transform 0x0 0 1 -1 0x30 text 0x0 (txt)]]
; = Ultimate challenge - mixed reversals and mirrors
myfont: make font! [name: "Courier New" size: 12]
txt1: reverse copy "L V t M t t t !"
txt2: reverse copy " eonardo da nc wro e rrored ex -- ou can oo "
txt3: reverse copy " y "
txt4: reverse copy " i i i "
view compose/deep [box 550x30 draw [
font myfont
transform 0x0 0 1 -1 0x28 [text 0x0 (txt1)]
transform 0x0 0 1 -1 0x30 [text 0x0 (txt2)]
transform 0x0 0 1 -1 0x32 [text 0x0 (txt3)]
transform 0x0 0 -1 1 550x0 [text 0x11 (txt4)]
]]
; = Totally overlapped
txt2: reverse copy txt1: "Leonardo da Vinci wrote Mirrored text -- you can too!"
view compose/deep [box 290x30 draw [
transform 0x0 0 -1 1 285x0 [text 0x0 (txt1)]
transform 0x0 0 1 -1 0x20 [text 0x0 (txt2)]
]]
; = Partially overlapped
txt2: reverse copy txt1: "Leonardo da Vinci wrote Mirrored text -- you can too!"
view compose/deep [box 290x30 draw [
transform 0x0 0 -1 1 285x0 [text 0x0 (txt1)]
transform 0x0 0 1 -1 0x15 [text 0x0 (txt2)]]
]
; = Leonardo script elongated and slanted
myfont: make font! [name: "Lucida Sans Unicode" size: 12 style: 'bold anti-alias?: yes]
txt: copy "Leonardo da Vinci wrote Mirrored text -- you can too!" view compose/deep [box 480x30 draw [font myfont skew 15 0 transform 0x0 0 -1 2 470x-10 text 0x0 (txt)]]
}
mirror: func [t [string!] /view /with fnt /local tx bx s][
if with [set '_font fnt]
layout/only compose either with [[tx: text font _font (t)]][[tx: text (t)]]
s: size-text tx
x: either with [_font/size][2]
bx: compose/deep [box (as-pair s/x + x s/y) draw [transform 0x0 0 -1 1 (as-pair s/x + x 0) text 0x0 (t)]]
if with [insert last bx [font _font]]
;probe bx
either view [system/words/view bx][bx]
]
comment {
; Some examples:
mirror/view "Try some leonardic writing!"
view compose/only [panel gold (mirror "Try some leonardic writing!")]
f: make font! [name: "Lucida Sans Unicode" size: 26 style: [italic]] mirror/with/view "Leonardo da Vinci wrote mirrored text - you can too!" f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment