Skip to content

Commit

Permalink
Use source-style shade glyphs
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Aug 3, 2017
1 parent 8672b3b commit 3e9949c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
36 changes: 19 additions & 17 deletions glyphs/symbol-geometric.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -457,39 +457,41 @@ export : define [apply] : begin
line-to 0 (-font.OS_2.usWinDescent)
save 'fullblock' 0x2588

define [Shade fn] : glyph-construction
define [Shade steps fill] : glyph-construction
local top font.OS_2.usWinAscent
local bottom (-font.OS_2.usWinDescent)
local segx 6
local segy 16
local g : create-glyph : glyph-construction : begin
include : ForceUpright
foreach j [range 0 segx] : foreach k [range 0 segy] : if [fn j k] : begin
start-from [mix 0 WIDTH (j / segx)] [mix bottom top (k / segy)]
line-to [mix 0 WIDTH (j / segx)] [mix bottom top ((k + 1) / segy)]
line-to [mix 0 WIDTH ((j + 1) / segx)] [mix bottom top ((k + 1) / segy)]
line-to [mix 0 WIDTH ((j + 1) / segx)] [mix bottom top (k / segy)]
include g
if (FULLWIDTH > WIDTH) : begin
apply-transform : Translate (FULLWIDTH - WIDTH) 0
include g
local sw : (top - bottom) / steps * fill
include : intersection
create-glyph : glyph-construction
foreach j [range 0 (steps * 2 + 2)] : begin
local y0 : mix top bottom (j / steps)
local y1 : y0 + top - bottom
start-from 0 (y0 - sw / 2)
line-to FULLWIDTH (y1 - sw / 2)
line-to FULLWIDTH (y1 + sw / 2)
line-to 0 (y0 + sw / 2)
spiro-outline
corner 0 bottom
corner 0 top
corner FULLWIDTH top
corner FULLWIDTH bottom

sketch # lightshade
set-width FULLWIDTH
include : ForceUpright
include : Shade ([j k] => ((k % 2) && (j + (k - 1) / 2) % 2))
include : Shade 2 (1 / 8)
save 'lightshade' 0x2591

sketch # mediumshade
set-width FULLWIDTH
include : ForceUpright
include : Shade ([j k] => ((j + k) % 2))
include : Shade 4 (1 / 4)
save 'mediumshade' 0x2592

sketch # heavyshade
set-width FULLWIDTH
include : ForceUpright
include : Shade ([j k] => ((k % 2) || (j + k / 2) % 2))
include : Shade 8 (1 / 2)
save 'heavyshade' 0x2593

foreach [fill : range 1 8] : begin
Expand Down
2 changes: 1 addition & 1 deletion support/spirokit.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export : define [SetupBuilders args] : begin
g1.include item
set g1.contours : g1.contours.map Glyph.contourToStandardCubic
local c1 : ShapeOps.boole operator g.contours g1.contours ShapeOps.fillRules.nonzero ShapeOps.fillRules.nonzero 2048
set g.contours : c1.map Glyph.contourToStandardCubic
set g.contours : c1.map : lambda [c] : [Glyph.contourToStandardCubic c].reverse
if [not dontinc] : this.include g
return g

Expand Down

0 comments on commit 3e9949c

Please sign in to comment.