Skip to content

Commit

Permalink
feat: Support more rough features
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Jan 13, 2024
1 parent 1b49d34 commit 470976b
Show file tree
Hide file tree
Showing 18 changed files with 1,601 additions and 462 deletions.
16 changes: 15 additions & 1 deletion examples/framebox.sil
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,18 @@ [email protected]\par
\end{roughbox}
\end{center}

\end{document}
\bigskip

\begin{center}
\begin[padding=1em, bordercolor=#ff7f50, fillcolor=#ecebbd, fillstyle=cross-hatch, enlarge=true]{roughbox}
\begin[valign=middle,width=80%fw,minimize=true]{parbox}
\begin{center}
\font[weight=700]{Sherlock Holmes}\par
221b Baker Street — London NW1 6XE\par
[email protected]\par
\end{center}
\end{parbox}
\end{roughbox}
\end{center}

\end{document}
2 changes: 1 addition & 1 deletion examples/tables.sil
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@
\font[features=+smcp]{Table 3.}
\end{center}

\end{document}
\end{document}
49 changes: 47 additions & 2 deletions packages/framebox/graphics/renderer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
-- one.
--

local RoughGenerator = require("packages.framebox.graphics.rough").RoughGenerator
local RoughGenerator = require("packages.framebox.rough-lua.generator").RoughGenerator

-- HELPERS

Expand Down Expand Up @@ -247,6 +247,18 @@ function DefaultPainter.curlyBrace (_, x1, y1 , x2 , y2, width, thickness, curvy
}
end

function DefaultPainter.ellipse ()
SU.error("Ellipse not implemented in DefaultPainter")
end

function DefaultPainter.circle ()
SU.error("Circle not implemented in DefaultPainter")
end

function DefaultPainter.arc ()
SU.error("Arc not implemented in DefaultPainter")
end

function DefaultPainter.draw (_, drawable, clippable)
local o = drawable.options
local path
Expand Down Expand Up @@ -306,6 +318,18 @@ function RoughPainter:rectangle (x, y , w , h, options)
return self.gen:rectangle(x, y , w , h, options)
end

function RoughPainter:ellipse (x, y , w , h, options)
return self.gen:ellipse(x, y , w , h, options)
end

function RoughPainter:circle (x, y , diameter, options)
return self.gen:circle(x, y , diameter, options)
end

function RoughPainter:arc (x, y , w , h, start, stop, closed, options)
return self.gen:arc(x, y , w , h, start, stop, closed, options)
end

function RoughPainter.rectangleShadow ()
SU.error("Rectangle shadow not implemented in RoughPainter")
end
Expand Down Expand Up @@ -337,7 +361,13 @@ function RoughPainter:draw (drawable)
"S"
}, " ")
elseif drawing.type == "fillPath" then
SU.error("Path filling not yet implemented.")
print("fillPath")
path = table.concat({
self:opsToPath(drawing, precision),
makeColorHelper(o.fill, false),
_r(o.strokeWidth), "w",
"f"
}, " ")
elseif drawing.type == "fillSketch" then
path = table.concat({
self:opsToPath(drawing, precision),
Expand Down Expand Up @@ -386,6 +416,21 @@ function PathRenderer:rectangle (x, y , w , h, options)
return self.adapter:draw(drawable)
end

function PathRenderer:ellipse (x, y , w , h, options)
local drawable = self.adapter:ellipse(x, y, w, h, options)
return self.adapter:draw(drawable)
end

function PathRenderer:circle (x, y , w , h, options)
local drawable = self.adapter:circle(x, y, w, h, options)
return self.adapter:draw(drawable)
end

function PathRenderer:arc (x, y , w , h, start, stop, closed, options)
local drawable = self.adapter:arc(x, y, w, h, start, stop, closed, options)
return self.adapter:draw(drawable)
end

function PathRenderer:rectangleShadow (x, y , w , h, s, options)
local drawable = self.adapter:rectangle(x + s, y + s, w, h, options)
local cliparea = self.adapter:rectangleClip(x, y, w, h, s)
Expand Down
Loading

0 comments on commit 470976b

Please sign in to comment.