13

Is there a way to fill a sign, say the sign ' / ', with red in steps?

Because, I ask myself if I could create sth. like that, using the corresponding character from a matching font (in the picture U+3042 (12354)):

enter image description here

No MWE:

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\begin{document}
Animate\tikz[scale=11, transform shape]\node{/};
\end{document}
2
  • Not using font files directly. It would involve quite a bit of handwork. On the other hand, if you have glyph examples based on plain strokes (as opposed to filled outlines) it could be done along the lines of this answer: tex.stackexchange.com/a/474914 .
    – AlexG
    Commented Jul 16, 2020 at 11:14
  • Done! However, there are several unnecessary points which you need fix by yourself ... :-)
    – user213378
    Commented Aug 1, 2020 at 10:05

1 Answer 1

13

Finished.

import animate;

settings.tex="xelatex";
settings.outformat="pdf"; 
texpreamble("\usepackage{CJK}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS}
\AtBeginDocument{\begin{CJK*}{UTF8}{name}}
\AtEndDocument{\clearpage\end{CJK*}}");
animation Ani;
unitsize(1cm);
path[] Asymptote=texpath("あ");
// pen[] p={red,green,blue};
/*
for (int i=0; i <Asymptote.length; ++i)
{
  draw(Asymptote[i],p[i]);
}
*/
pair[] a,b,c;
pair labdira,labdirb,labdirc;

  for(int j=0;j<size(Asymptote[0]);++j){
    a.push(point(Asymptote[0],j));
  }
    for(int j=0;j<size(Asymptote[1]);++j){
    b.push(point(Asymptote[1],j));
  }
    for(int j=0;j<size(Asymptote[2]);++j){
    c.push(point(Asymptote[2],j));
  }

path p1=subpath(Asymptote[0],21,22)--subpath(Asymptote[0],25,26);
path p2=reverse(subpath(Asymptote[0],19,20))--reverse(subpath(Asymptote[0],27,28));
path firstpath;
for(real r=0; r<20; ++r){
save();
firstpath=reverse(subpath(p2,0,reltime(p2,r/20)))--subpath(Asymptote[0],20,21)--subpath(p1,0,reltime(p1,r/20))--cycle;
fill(firstpath, (r != 0) ? black : invisible);
Ani.add();
restore();
}
fill(reverse(subpath(p2,0,reltime(p2,1)))--subpath(Asymptote[0],20,21)--subpath(p1,0,reltime(p1,1))--cycle);

path q1=reverse(subpath(Asymptote[0],22,23))--reverse(subpath(Asymptote[0],18,19))
               --subpath(Asymptote[2],1,0)--reverse(subpath(Asymptote[0],12,13));
path q2=subpath(Asymptote[0],24,25)--subpath(Asymptote[0],28,29)
               --subpath(Asymptote[1],2,3)--subpath(Asymptote[0],10,11);
path secondpath;

for(real r=0; r<20; ++r){
save();
secondpath=reverse(subpath(q1,0,reltime(q1,r/20)))--subpath(Asymptote[0],23,24)--subpath(q2,0,reltime(q2,r/20))--cycle;
fill(secondpath,(r != 0) ? black : invisible);
Ani.add();
restore();
}
fill(reverse(subpath(q1,0,reltime(q1,1)))--subpath(Asymptote[0],23,24)--subpath(q2,0,reltime(q2,1))--cycle);

pair A=b[0]+2*dir(subpath(Asymptote[1],3,4));
pair B=a[9]+2*dir(reverse(subpath(Asymptote[0],9,10)));
pair Aa=intersectionpoint(subpath(Asymptote[0],1,2),b[0]--A);
pair Bb=intersectionpoint(subpath(Asymptote[0],1,2),a[9]--B);

path tr=subpath(Asymptote[1],4,3)--subpath(Asymptote[2],6,1)
                   --subpath(Asymptote[1],2,0)
                   --reverse(subpath(Asymptote[0],6,9));
path tr1=subpath(Asymptote[0],9,10)
                   --subpath(Asymptote[0],13,18)
                   --subpath(Asymptote[0],0,5);
path kk;
for (int i=0; i<=20; ++i){
save();
  kk=reverse(subpath(Aa--tr,0,reltime(Aa--tr,i/20)))--Aa--Bb--subpath(Bb--tr1,0,reltime(Bb--tr1,i/20))--cycle;
  fill(kk,(i != 0 ) ? black : invisible);
Ani.add();
restore();
}

erase();
Ani.movie(BBox(2mm,Fill(pink)));

enter image description here

Updated!

This is what you want!

Step 1:

settings.tex="xelatex";
settings.outformat="pdf"; 
texpreamble("\usepackage{CJK}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS}
\AtBeginDocument{\begin{CJK*}{UTF8}{name}}
\AtEndDocument{\clearpage\end{CJK*}}");
unitsize(1cm);
path[] Asymptote=texpath("あ");
pen[] p={red,green,blue}; p.cyclic=true;

for (int i=0; i <Asymptote.length; ++i)
{
  draw(Asymptote[i],p[i]);
}

pair[] a,b,c;
pair labdira,labdirb,labdirc;

  for(int j=0;j<size(Asymptote[0]);++j){
    a.push(point(Asymptote[0],j));
    labdira=rotate(-90)*dir(Asymptote[0],j);
    dot("$\scriptsize "+string(j)+"$",a[j],labdira);
  }
    for(int j=0;j<size(Asymptote[1]);++j){
    b.push(point(Asymptote[1],j));
    labdirb=rotate(-90)*dir(Asymptote[1],j);
    dot("$\scriptsize "+string(j)+"$",b[j],labdirb);
  }
    for(int j=0;j<size(Asymptote[2]);++j){
    c.push(point(Asymptote[2],j));
    labdirc=rotate(-90)*dir(Asymptote[2],j);
    dot("$\scriptsize "+string(j)+"$",c[j],labdirc);
  }

enter image description here

Step 2:

import animate;

settings.tex="xelatex";
settings.outformat="pdf"; 
texpreamble("\usepackage{CJK}
\usepackage{fontspec}
\setmainfont{Arial Unicode MS}
\AtBeginDocument{\begin{CJK*}{UTF8}{name}}
\AtEndDocument{\clearpage\end{CJK*}}");
animation Ani;
unitsize(1cm);
path[] Asymptote=texpath("あ");
pen[] p={red,green,blue};

for (int i=0; i <Asymptote.length; ++i)
{
  draw(Asymptote[i],p[i]);
}

pair[] a,b,c;
pair labdira,labdirb,labdirc;

  for(int j=0;j<size(Asymptote[0]);++j){
    a.push(point(Asymptote[0],j));
    /*labdira=rotate(-90)*dir(Asymptote[0],j);
    dot("$\scriptsize "+string(j)+"$",a[j],labdira);*/
  }
    for(int j=0;j<size(Asymptote[1]);++j){
    b.push(point(Asymptote[1],j));
    /*labdirb=rotate(-90)*dir(Asymptote[1],j);
    dot("$\scriptsize "+string(j)+"$",b[j],labdirb);*/
  }
    for(int j=0;j<size(Asymptote[2]);++j){
    c.push(point(Asymptote[2],j));
    /*labdirc=rotate(-90)*dir(Asymptote[2],j);
    dot("$\scriptsize "+string(j)+"$",c[j],labdirc);*/
  }
picture pic1;
pair Tmin=(a[21].x,a[20].y),Tmax=(a[27].x,a[26].y);
path g1=subpath(Asymptote[0],19,22)--subpath(Asymptote[0],25,28)--cycle;
for(real r=0; r<20; ++r){
save();
fill(pic1,g1);
clip(pic1,box(Tmin,relpoint((Tmin.x,Tmax.y)--Tmax,r/20)));
add(pic1);
Ani.add();
restore();
}
fill(g1);

picture pic2;
pair Tmin=(min(Asymptote[0]).x,a[12].y),Tmax=max(Asymptote[0]);
path g2=subpath(Asymptote[0],22,25)--
               //subpath(Asymptote[0],28,0)--
               a[28]--a[0]--
               subpath(Asymptote[1],2,3)--
               subpath(Asymptote[0],10,13)--
               subpath(Asymptote[2],0,1)--
               subpath(Asymptote[0],18,19)--cycle;
for(real r=0; r<20; ++r){
save();
fill(pic2,g2);
clip(pic2,box(relpoint((Tmin.x,Tmax.y)--Tmin,r/20),Tmax));
add(pic2);
Ani.add();
restore();
}
fill(g2);

picture pic3;
path tr=subpath(Asymptote[1],4,3)--subpath(Asymptote[2],6,1)
                   --subpath(Asymptote[1],2,0)
                   --reverse(subpath(Asymptote[0],6,9));
path tr1=subpath(Asymptote[0],9,10)
                   --subpath(Asymptote[0],13,18)
                   --subpath(Asymptote[0],0,5);
path kk;
for (int i=0; i<=20; ++i){
save();
  kk=reverse(subpath(tr,0,reltime(tr,i/20)))--b[0]--a[9]--subpath(tr1,0,reltime(tr1,i/20))--cycle;
  fill(pic3,kk);
  add(pic3);
Ani.add();
restore();
}

erase();
Ani.movie(BBox(3mm,Fill(white)));

enter image description here

This is my consideration for keyword "A" with Asymptote.

As AlexG's comment: It would involve quite a bit of handwork.

Only for compare and checking purpose.

import animate;
settings.tex="pdflatex"; 
settings.outformat="pdf"; 

animation Ani;
size(10cm);

path[] Asymptote=texpath(Label("A"));

pen[] p={red,green,blue}; p.cyclic=true;

for (int i=0; i <Asymptote.length; ++i)
{
  draw(Asymptote[i],p[i]);
}
pair[] a,b;
pair labdira,labdirb;

  for(int j=0;j<size(Asymptote[0]);++j){
    a.push(point(Asymptote[0],j));
    /*labdira=rotate(-90)*dir(Asymptote[0],j);
    dot("$\scriptsize "+string(j)+"$",a[j],labdira);*/
  }
    for(int j=0;j<size(Asymptote[1]);++j){
    b.push(point(Asymptote[1],j));
    /*labdirb=rotate(-90)*dir(Asymptote[1],j);
    dot("$\scriptsize "+string(j)+"$",b[j],labdirb);*/
  }

pair M=intersectionpoint(subpath(Asymptote[0],0,1),b[0]--b[0]+(b[0]-b[2]));
path d=subpath(Asymptote[0],intersect(subpath(Asymptote[0],0,1),b[0]--b[0]+(b[0]-b[2]))[0],11)--b[2]--b[0]--cycle;
path q=b[0]--b[1]--subpath(Asymptote[0],12,20)--subpath(Asymptote[0],0,intersect(subpath(Asymptote[0],0,1),b[0]--b[0]+(b[0]-b[2]))[0])--cycle;
//dot(M);
pair K=min(Asymptote[0]),U=max(Asymptote[0]);
draw(box(K,U));

picture pic1;
for(real r=0; r<20; ++r){
save();
fill(pic1,d,red);
clip(pic1,box(K,relpoint((U.x,K.y)--U,r/20)));
add(pic1);
Ani.add();
restore();
}
fill(d,red);
picture pic2;
for(real r=0; r<20; ++r){
save();
fill(pic2,q,red);
clip(pic2,box(relpoint((K.x,U.y)--K,r/20),U));
add(pic2);
Ani.add();
restore();
}
fill(q,red);
pair Mi=(a[11].x,K.y),Ma=(a[12].x,U.y);
picture pic3;

for(real r=0; r<=20; ++r){
save();
fill(pic3,(a[11]--b[2]--b[1]--a[12]--cycle),red);
clip(pic3,box(Mi,relpoint((Mi.x,Ma.y)--Ma,r/20)));
add(pic3);
Ani.add();
restore();
}

erase();
Ani.movie(BBox(3mm,Fill(white)));

enter image description here

3
  • 3
    Wow, this is quite impressive! I have to study your procedure.
    – cis
    Commented Aug 1, 2020 at 10:19
  • 1
    The bronze medal is well merited. I'm glad there's a great user with Asymptote.
    – Sebastiano
    Commented Aug 2, 2020 at 8:21
  • @Sebastiano Thanks for +1 and your comment.
    – user213378
    Commented Aug 2, 2020 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .