Comments (8)
Drat: I had hoped to avoid having to manually save/restore stuff as this more-or-less relies on internals of how dvips
sets things up. But I can't think of another way around this other than using the approach pgf
does - I guess I'll need to adjust.
from latex3.
Not sure how safe it is but adding this to the example...
\cs_set_protected:Npn \__draw_backend_scope_begin:
{ \__draw_backend_literal:n {
@endspecial ~ save ~ @beginspecial } }
\cs_set_protected:Npn \__draw_backend_scope_end:
{ \__draw_backend_literal:n { @endspecial ~ restore ~ @beginspecial} }
produces
dvisvgm also manages to understand this dvips syntax enough and the resulting svg looks like
from latex3.
@davidcarlisle Your idea and my original approach to the box insertion share a common issue. By issuing @endspecial
, a scope is closed. That means that if a user has a setting before the box, e.g. a transformation or colour change, it would not apply after the box. For example, before the change I've commited,
\documentclass[border=10pt]{standalone}
\usepackage{l3draw}
\begin{document}
\ExplSyntaxOn
\draw_begin:
\color_select:n { red }
\draw_path_circle:nn { 0cm , 0cm } { 1cm }
\draw_path_use_clear:n { stroke }
\hbox_set:Nn \l_tmpa_box {foo}
\draw_box_use:N \l_tmpa_box
\draw_path_circle:nn { 0cm , 0cm } { 2cm }
\draw_path_use_clear:n { stroke }
\draw_end:
\ExplSyntaxOff
\end{document}
gives the wrong result with dvips
. So I think a change is needed: I'll make some more notes in the sources and add a test or two.
from latex3.
I think things are OK now - testing suggests so.
from latex3.
I saw as I posted that you'd just done a checkin saving and restoring explicitly (which looks cleaner anyway than relying on dvips output quite so much). but I'm surprised it closes a scope if used as suggested. The idea was you'd end up with
@beginspecial % from dvips
@endspecial, % from the \special content
save % from the \special content
@beginspecial % from the \special content
@endspecial, % from dvips
so the save is in the outer context and the two empty scopes do nothing, then you do the same wtih restore so following text should be in the original scope.
from latex3.
I meant that if you end up with for example
@beginspecial % from start-of-picture
1.0 0.0 0.0 TeXcolorrgb % from a color
@endspecial, % from the \special content
save % from the \special content
@beginspecial % from the \special content
... % Content here
@endspecial, % from dvips
then the content will come out black not red. As a concrete example, using dvips
try
\documentclass{article}
\usepackage{l3draw}
\begin{document}
\ExplSyntaxOn
\cs_set_protected:Npn \__draw_backend_scope_begin:
{ \__draw_backend_literal:n {
@endspecial ~ save ~ @beginspecial } }
\cs_set_protected:Npn \__draw_backend_scope_end:
{ \__draw_backend_literal:n { @endspecial ~ restore ~ @beginspecial} }
\draw_begin:
\color_select:n { red }
\draw_scope_begin:
\draw_scope_end:
\draw_path_moveto:n { 0cm, 0cm }
\draw_path_lineto:n { 10cm, 0cm }
\draw_path_moveto:n { 5cm, 0cm }
\draw_path_lineto:n { 5cm , 5cm }
\draw_path_use_clear:n { stroke }
\draw_end:
\ExplSyntaxOff
\end{document}
with and without the lines commented. (You also see the line thickness revert to the one not set by l3draw
.)
from latex3.
@davidcarlisle BTW, dvips
doesn't add @beginspecial
automatically, that comes from the \draw_begin:
implementation.
from latex3.
ah if you get stuf between the begin and end that would be bad:, agreed:-)
from latex3.
Related Issues (20)
- l3keys: properties `.cs_set...:N` in addition to `.cs_set...:Np` ones? HOT 3
- `\cctab_const:Nn` raises "Inconsistent local/global assignment" errors HOT 1
- `\prop_put_if_new:Nnn` vs `\prop_put_if_not_in:Nnn` HOT 2
- Symmetry/Consistency among fparray and intarray functions HOT 3
- \IfInstanceExistTF undefined with -dev formats HOT 2
- \iow_shell_open:Nn can't work
- Loading `expl3-generic.tex` in LuaMetaTeX fails with `expl3.lua:421: table index is nil` since TeX Live 2024 HOT 6
- l3pdf feature request: providing variants for pdf-object-related functions that expand their object name argument HOT 9
- visible spaces in l3sys-query results HOT 6
- Can't define a new fp function based on fact() HOT 1
- New iow function that respects `\showstream`
- support of CMYK colors in dvisvgm backend HOT 9
- peek_analysis_map_inline does not work for active space HOT 7
- char_generate:nn creates new text input level now? HOT 10
- (Not a bug) \tl_gset:Nx is no longer directly mapped to \xdef? HOT 5
- Inconsistent behavior for "c"-type ...item functions HOT 11
- peek_analysis_map_inline does not unwind input level for some reason HOT 1
- Tag 2024-05-08 not merged into main branch HOT 3
- l3backend-dvips.pro not found by kpsewhich despite being present HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from latex3.