Skip to content

Algoritmo di estrazione TikZ/PGF

Ciao, abbiamo trovato la soluzione alla tua ricerca, scorri verso il basso e la troverai di seguito.

Soluzione:

Come sottolinea JouleV, l'ellisse viene disegnata con quattro curve di Bezier. Se non si vuole cercare queste cose nel codice, si può sempre usare show path construction per vedere come viene costruito il percorso.

documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{decorations.pathreplacing}
begin{document}
begin{tikzpicture}[decoration={show path construction, % see p. 634 of the pgfmanual
    moveto code={
      fill [red] (tikzinputsegmentfirst) circle (2pt)
        node [fill=none, below] {moveto};},
    lineto code={
      draw [blue,->] (tikzinputsegmentfirst) -- (tikzinputsegmentlast)
        node [above] {lineto};
    },
    curveto code={
      draw [green!75!black,->] (tikzinputsegmentfirst) .. controls
        (tikzinputsegmentsupporta) and (tikzinputsegmentsupportb)
        ..(tikzinputsegmentlast) node [above] {curveto};
    },
    closepath code={
      draw [orange,->] (tikzinputsegmentfirst) -- (tikzinputsegmentlast)
        node [above] {closepath};}
}]
draw [rotate around={0.:(0.,0.)},line width=0.8pt,postaction=decorate] (0.,0.) ellipse (5.cm and 4.cm);
end{tikzpicture}
end{document}

enter image description here

Questo vale anche per i cerchi, ed è per questo che la rotazione di un cerchio può modificare il suo rettangolo di selezione.

pgfcorepathconstruct.code.tex, righe 892-1010:

% Append  an ellipse to the current path.
%
% #1 = center
% #2 = first axis
% #3 = second axis
%
% Example:
%
% % Add a circle of radius 3cm around the origin
% pgfpathellipse{pgforigin}{pgfxy(2,0)}{pgfxy(0,1)}
%
% % Draw a non-filled circle of radius 1cm around the point (1,1)
% pgfpathellipse{pgfxy(1,1)}{pgfxy(1,1)}{pgfxy(-2,2)}
% pgfstroke

defpgfpathellipse#1#2#3{%
  pgfpointtransformed{#1}% store center in xc/yc
  [email protected]=[email protected]%
  [email protected]=[email protected]%
  pgfpointtransformed{#2}%
  [email protected]=[email protected]% store first axis in xa/ya
  [email protected]=[email protected]%
  advance[email protected] by-[email protected]@x%
  advance[email protected] by-[email protected]@y%
  pgfpointtransformed{#3}%
  [email protected]=[email protected]% store second axis in xb/yb
  [email protected]=[email protected]%
  advance[email protected] by-[email protected]@x%
  advance[email protected] by-[email protected]@y%
  {%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    [email protected]@moveto{[email protected]}{[email protected]}%
  }%
  [email protected]=0.55228475[email protected]% first arc
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  edef[email protected]{[email protected]the[email protected][email protected]the[email protected]}%
  [email protected]=0.55228475[email protected]%
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  {%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    [email protected]%
    [email protected]@curveto{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}%
  }%
  [email protected]=-[email protected]% flip first axis
  [email protected]=-[email protected]%
  [email protected]=0.55228475[email protected]% second arc
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  edef[email protected]{[email protected]the[email protected][email protected]the[email protected]}%
  [email protected]=0.55228475[email protected]%
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  {%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    [email protected]%
    [email protected]@curveto{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}%
  }%
  [email protected]=-[email protected]% flip second axis
  [email protected]=-[email protected]%
  [email protected]=0.55228475[email protected]% third arc
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  edef[email protected]{[email protected]the[email protected][email protected]the[email protected]}%
  [email protected]=0.55228475[email protected]%
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  {%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    [email protected]%
    [email protected]@curveto{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}%
  }%
  [email protected]=-[email protected]% flip first axis once more
  [email protected]=-[email protected]%
  [email protected]=0.55228475[email protected]% fourth arc
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  edef[email protected]{[email protected]the[email protected][email protected]the[email protected]}%
  [email protected]=0.55228475[email protected]%
  [email protected]=0.55228475[email protected]%
  advance[email protected] by[email protected]%
  advance[email protected] by[email protected]%
  {%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    advance[email protected] by[email protected]%
    [email protected]%
    [email protected]@curveto{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}{[email protected]}%
  }%
  [email protected]@closepath%
  [email protected]@moveto{[email protected]}{[email protected]}%
}

Leggendo i commenti si capisce che l'opzione ellipse è tracciata da quattro curve diverse (ogni curva è disegnata con un [email protected]@curveto).

Si noti che lo stesso accade con circle.



Utilizzate il nostro motore di ricerca

Ricerca
Generic filters

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.