Drawing stars/similar with TikzHow to draw this pyramid with TeX?How to create dotted counter?Using...

Why can't we use freedom of speech and expression to incite people to rebel against government in India?

What can I do if someone tampers with my SSH public key?

Why are special aircraft used for the carriers in the United States Navy?

What is a term for a function that when called repeatedly, has the same effect as calling once?

PTiJ: How should animals pray?

Naming Characters after Friends/Family

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

What does "rhumatis" mean?

Does the in-code argument passing conventions used on PDP-11's have a name?

Is divide-by-zero a security vulnerability?

Python 3.6+ function to ask for a multiple-choice answer

Ultrafilters as a double dual

Did Amazon pay $0 in taxes last year?

Paper published similar to PhD thesis

I can't die. Who am I?

Are Wave equations equivalent to Maxwell equations in free space?

Deal the cards to the players

Dukha vs legitimate need

Sundering Titan and basic normal lands and snow lands

Is there a frame of reference in which I was born before I was conceived?

An Undercover Army

How spaceships determine each other's mass in space?

Is being socially reclusive okay for a graduate student?

Remove object from array based on array of some property of that object



Drawing stars/similar with Tikz


How to draw this pyramid with TeX?How to create dotted counter?Using pgfmathparse and ifnum for a TikZ checkerboardHow to draw star in TikZ backgroundGet partly filled circle symbol scale linearly with parametercircle symbol instead of star symbol in ratingTikZ: add “alt tag/caption/invisible text” for accessibilityAdd the following skill format to the moderncvHow to add 25/50/75/100% filled circles to a table?Remove whitespace around tikz picture in running textTikz drawing a ring with nodesDrawing complex diagrams with TikZ using gradientsTikz shape similar to rectangle with selective drawing of bordersDrawing diagrams of higher categories with TikZdrawing with TikZDrawing a block diagram with TiKzDrawing unstructured grids with TikzPhasor summation using tikzDrawing a CNN with TikzDrawing similar picture with tikz













33















I'm writing a review for a book at the moment, and I thought I'd be clever and show off what LaTeX is capable of by adding a x-out-of-y stars graphic. Tikz can do many things so I would have thought that a trick like this would be fairly trivial, however it seems that I cannot figure out a macro to draw the shapes at the right size, let alone fancy tricks such as half-filled stars or something similar. I think the code I have so far might be headed in the right direction:



usepackage{tikz}
usetikzlibrary{shapes.geometric}
usetikzlibrary{calc,shadows}

newcommand*starfill{%
tikz[baseline=(key.base),scale=-3]
node[star, star points=5, star point ratio=2.25, fill=black, draw](key) {S};
}


I've tried to start by drawing a single star shape, but ideally I'd like to define like starsranking{number}{total} that will output the appropriate shaded number of stars out of total. Is this doable? It doesn't sound particularly difficult.










share|improve this question

























  • The star, star points=5, star point ratio=2.25 are your own options, aren't there? You should have a look at foreach. You need two: one from 1 to starpoints to make the filled stars and one for starpoints+1 to 5. The half-filled stars should be do-able with an clipped fill-path.

    – Martin Scharrer
    Feb 18 '11 at 9:28
















33















I'm writing a review for a book at the moment, and I thought I'd be clever and show off what LaTeX is capable of by adding a x-out-of-y stars graphic. Tikz can do many things so I would have thought that a trick like this would be fairly trivial, however it seems that I cannot figure out a macro to draw the shapes at the right size, let alone fancy tricks such as half-filled stars or something similar. I think the code I have so far might be headed in the right direction:



usepackage{tikz}
usetikzlibrary{shapes.geometric}
usetikzlibrary{calc,shadows}

newcommand*starfill{%
tikz[baseline=(key.base),scale=-3]
node[star, star points=5, star point ratio=2.25, fill=black, draw](key) {S};
}


I've tried to start by drawing a single star shape, but ideally I'd like to define like starsranking{number}{total} that will output the appropriate shaded number of stars out of total. Is this doable? It doesn't sound particularly difficult.










share|improve this question

























  • The star, star points=5, star point ratio=2.25 are your own options, aren't there? You should have a look at foreach. You need two: one from 1 to starpoints to make the filled stars and one for starpoints+1 to 5. The half-filled stars should be do-able with an clipped fill-path.

    – Martin Scharrer
    Feb 18 '11 at 9:28














33












33








33


21






I'm writing a review for a book at the moment, and I thought I'd be clever and show off what LaTeX is capable of by adding a x-out-of-y stars graphic. Tikz can do many things so I would have thought that a trick like this would be fairly trivial, however it seems that I cannot figure out a macro to draw the shapes at the right size, let alone fancy tricks such as half-filled stars or something similar. I think the code I have so far might be headed in the right direction:



usepackage{tikz}
usetikzlibrary{shapes.geometric}
usetikzlibrary{calc,shadows}

newcommand*starfill{%
tikz[baseline=(key.base),scale=-3]
node[star, star points=5, star point ratio=2.25, fill=black, draw](key) {S};
}


I've tried to start by drawing a single star shape, but ideally I'd like to define like starsranking{number}{total} that will output the appropriate shaded number of stars out of total. Is this doable? It doesn't sound particularly difficult.










share|improve this question
















I'm writing a review for a book at the moment, and I thought I'd be clever and show off what LaTeX is capable of by adding a x-out-of-y stars graphic. Tikz can do many things so I would have thought that a trick like this would be fairly trivial, however it seems that I cannot figure out a macro to draw the shapes at the right size, let alone fancy tricks such as half-filled stars or something similar. I think the code I have so far might be headed in the right direction:



usepackage{tikz}
usetikzlibrary{shapes.geometric}
usetikzlibrary{calc,shadows}

newcommand*starfill{%
tikz[baseline=(key.base),scale=-3]
node[star, star points=5, star point ratio=2.25, fill=black, draw](key) {S};
}


I've tried to start by drawing a single star shape, but ideally I'd like to define like starsranking{number}{total} that will output the appropriate shaded number of stars out of total. Is this doable? It doesn't sound particularly difficult.







tikz-pgf symbols diagrams asymptote






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 mins ago









g.kov

17.4k13976




17.4k13976










asked Feb 18 '11 at 9:16









RobbieRobbie

1,18821424




1,18821424













  • The star, star points=5, star point ratio=2.25 are your own options, aren't there? You should have a look at foreach. You need two: one from 1 to starpoints to make the filled stars and one for starpoints+1 to 5. The half-filled stars should be do-able with an clipped fill-path.

    – Martin Scharrer
    Feb 18 '11 at 9:28



















  • The star, star points=5, star point ratio=2.25 are your own options, aren't there? You should have a look at foreach. You need two: one from 1 to starpoints to make the filled stars and one for starpoints+1 to 5. The half-filled stars should be do-able with an clipped fill-path.

    – Martin Scharrer
    Feb 18 '11 at 9:28

















The star, star points=5, star point ratio=2.25 are your own options, aren't there? You should have a look at foreach. You need two: one from 1 to starpoints to make the filled stars and one for starpoints+1 to 5. The half-filled stars should be do-able with an clipped fill-path.

– Martin Scharrer
Feb 18 '11 at 9:28





The star, star points=5, star point ratio=2.25 are your own options, aren't there? You should have a look at foreach. You need two: one from 1 to starpoints to make the filled stars and one for starpoints+1 to 5. The half-filled stars should be do-able with an clipped fill-path.

– Martin Scharrer
Feb 18 '11 at 9:28










5 Answers
5






active

oldest

votes


















49














Here's the code for fully filled stars, now slightly improved thanks to Andrew Stacey's answer to the checkerboard question:



documentclass{minimal}
usepackage{tikz}
usetikzlibrary{shapes.geometric}

newcommandscore[2]{
pgfmathsetmacropgfxa{#1+1}
tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]
begin{tikzpicture}[baseline]
foreach i in {1,...,#2} {
pgfmathparse{(i<=#1?"yellow":"gray")}
edefstarcolor{pgfmathresult}
draw (i*1.75ex,0) node[name=stari,scorestars,fill=starcolor] {};
}
end{tikzpicture}
}

begin{document}
score{0}{5} A meagre result.

score{4}{5} Much better

score{5}{5} Perfect score!

end{document}


ranking stars with tikz





And here's the much more elaborate, much more pointless, floating point scoring star macro (I'll leave the simple one in as well, it's a lot more usable):



documentclass{article}
usepackage{tikz}
usetikzlibrary{shapes.geometric,calc}

newcommandscore[2]{
pgfmathsetmacropgfxa{#1+1}
tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
begin{tikzpicture}[baseline]
foreach i in {1,...,#2} {
pgfmathparse{(i<=#1?"yellow":"gray")}
edefstarcolor{pgfmathresult}
draw (i*1em,0) node[name=stari,scorestars,fill=starcolor] {};
}
pgfmathparse{(#1>int(#1)?int(#1+1):0}
letpartstar=pgfmathresult
ifnumpartstar>0
pgfmathsetmacrostarpart{#1-(int(#1))}
path [clip] ($(starpartstar.outer point 3)!(starpartstar.outer point 2)!(starpartstar.outer point 4)$) rectangle
($(starpartstar.outer point 2 |- starpartstar.outer point 1)!starpart!(starpartstar.outer point 1 -| starpartstar.outer point 5)$);
fill (partstar*1em,0) node[scorestars,fill=yellow] {};
fi

,end{tikzpicture}
}

begin{document}
smallscore{2}{5} A meagre result.

Huge{score{4.4}{5} Wooo!}

end{document}


enter image description here






share|improve this answer


























  • Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

    – Matthew Leingang
    Feb 18 '11 at 16:06






  • 1





    Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

    – Loop Space
    Feb 18 '11 at 18:24











  • That is brilliant. Wow.

    – Robbie
    Feb 20 '11 at 12:11











  • One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

    – Robbie
    Feb 20 '11 at 12:18











  • @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

    – Jake
    Feb 20 '11 at 20:06



















14














enter image description here



Asymptote version stars.asy:



size(200);
real sc=20;

picture score(real scoreMark=0,guide star=scale(sc)*unitcircle, int maxscore=5,
pen linePen=nullpen, pen bgPen=darkblue, pen scorePen=orange){
picture pic;
guide[] g;
for(int i=0;i<maxscore;++i){
g.push(shift((2sc*i,0))*star);
}
assert(maxscore>0 && scoreMark>=0 && scoreMark<=maxscore,"***** Wrong score.");
fill(pic,box((-sc,-sc),(maxscore*2sc-sc,sc)),bgPen);
fill(pic,box((-sc,-sc),(scoreMark*2sc-sc,sc)),scorePen);
clip(pic,g);
draw(pic,g,linePen);
return pic;
}

guide star;
pair p;
for(int i=0;i<5;++i){
p=rotate(72*i)*N;
star=star--p;
star=star--(scale(0.382)*rotate(72*i+36)*N);
}
star=scale(sc)*(star--cycle);

add(score(scoreMark=1,star,maxscore=7),(0,0));
add(score(scoreMark=2,star,maxscore=7,linePen=lightred,bgPen=lightblue),(0,-3sc));
add(score(scoreMark=3.5,star,maxscore=5,linePen=lightred,bgPen=lightblue),(0,-6sc));
add(score(scoreMark=3.75,star,maxscore=4,linePen=olive,bgPen=white,scorePen=lightgreen),(0,-9sc));

add(score(4.2,bgPen=green+opacity(0.3),scorePen=red+opacity(0.5)),(0,3sc));


To get a standalone stars.pdf run asy -f pdf stars.asy.






share|improve this answer































    11














    With PSTricks.



    enter image description here



    documentclass[preview,border=12pt,varwidth]{standalone}
    usepackage{pstricks}
    usepackage{multido}
    SpecialCoor
    makeatletter
    defLoadPSVars{pstVerb{/ptcm {pst@numberpsunit div} bind def}}
    makeatother

    defpoints{}
    defStar{%
    xdefpoints{}% cleaning
    multido{iR=0+72,ir=36+72}{5}{xdefpoints{points (10pt;iR)(5pt;ir)}}
    expandafterpspolygonpoints}

    defRating#1{% #1: percentage
    psscalebox{0.35}{%
    begin{pspicture}(11pt,-11pt)(111pt,11pt)
    LoadPSVars
    psclip{pscustom{psLoop{5}{translate(20pt,0)Star}}}
    psframe*[linecolor=yellow](11pt,-11pt)(!#1 11 add ptcm 11 ptcm)
    endpsclip
    pscustom{psLoop{5}{translate(20pt,0)Star}}
    end{pspicture}}}

    begin{document}
    begin{enumerate}
    item Rating{100} PSTricks
    item Rating{50} Asymptote
    item Rating{20} Metapost
    item Rating{5} TikZ
    end{enumerate}
    end{document}


    Warning:





    • rput will not work inside pscustom. Use translate instead!


    • standalone discards my ptcm operator defined in the preamble, so I have to load it manually inside pspicture. It is sad!






    share|improve this answer





















    • 2





      TikZ, I am sorry. It is just an example!

      – kiss my armpit
      Apr 14 '13 at 10:02











    • @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

      – Black Mild
      Nov 20 '18 at 17:26



















    10














    I have written a package for ConTeXt that draws X out of Y graphics. It is primarily meant to draw numbers in presentations. It offers stars as one of the options:



    enter image description here



    usemodule[visualcounter]

    definepalet
    [star-colors]
    [active=yellow,
    past=yellow,
    future=gray]

    definevisualcounter
    [stars]
    [markers]
    [mpsetups=visualcounter::markers:star,
    width=1.5EmWidth,
    distance=0.25EmWidth,
    palette=star-colors,
    ]

    starttext

    startTEXpage[offset=2mm]
    startitemize
    item usevisualcounter[n=1, last=5]{stars} That's appalling!
    item usevisualcounter[n=2, last=5]{stars} A meagre result.
    item usevisualcounter[n=4, last=5]{stars} Woo!
    stopitemize
    stopTEXpage
    stoptext


    See documentation for more details.



    As the primary purpose of this module is to display page numbers, it does not support fractional values.






    share|improve this answer































      6














      Jake's answer is very good. Here's the extra half star:



      node[scorestars,fill=gray] {};
      path node[scorestars,fill=yellow] (s) {} [clip] (s.south west) rectangle (s.north);





      share|improve this answer



















      • 1





        ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

        – Loop Space
        Feb 18 '11 at 13:07











      • @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

        – Hendrik Vogt
        Feb 18 '11 at 13:15











      • @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

        – Matthew Leingang
        Feb 18 '11 at 13:44






      • 1





        @Matthew: Consider yourself asked.

        – Loop Space
        Feb 18 '11 at 13:47






      • 3





        @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

        – Matthew Leingang
        Feb 18 '11 at 16:00











      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f11390%2fdrawing-stars-similar-with-tikz%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      49














      Here's the code for fully filled stars, now slightly improved thanks to Andrew Stacey's answer to the checkerboard question:



      documentclass{minimal}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1.75ex,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      end{tikzpicture}
      }

      begin{document}
      score{0}{5} A meagre result.

      score{4}{5} Much better

      score{5}{5} Perfect score!

      end{document}


      ranking stars with tikz





      And here's the much more elaborate, much more pointless, floating point scoring star macro (I'll leave the simple one in as well, it's a lot more usable):



      documentclass{article}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric,calc}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1em,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      pgfmathparse{(#1>int(#1)?int(#1+1):0}
      letpartstar=pgfmathresult
      ifnumpartstar>0
      pgfmathsetmacrostarpart{#1-(int(#1))}
      path [clip] ($(starpartstar.outer point 3)!(starpartstar.outer point 2)!(starpartstar.outer point 4)$) rectangle
      ($(starpartstar.outer point 2 |- starpartstar.outer point 1)!starpart!(starpartstar.outer point 1 -| starpartstar.outer point 5)$);
      fill (partstar*1em,0) node[scorestars,fill=yellow] {};
      fi

      ,end{tikzpicture}
      }

      begin{document}
      smallscore{2}{5} A meagre result.

      Huge{score{4.4}{5} Wooo!}

      end{document}


      enter image description here






      share|improve this answer


























      • Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

        – Matthew Leingang
        Feb 18 '11 at 16:06






      • 1





        Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

        – Loop Space
        Feb 18 '11 at 18:24











      • That is brilliant. Wow.

        – Robbie
        Feb 20 '11 at 12:11











      • One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

        – Robbie
        Feb 20 '11 at 12:18











      • @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

        – Jake
        Feb 20 '11 at 20:06
















      49














      Here's the code for fully filled stars, now slightly improved thanks to Andrew Stacey's answer to the checkerboard question:



      documentclass{minimal}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1.75ex,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      end{tikzpicture}
      }

      begin{document}
      score{0}{5} A meagre result.

      score{4}{5} Much better

      score{5}{5} Perfect score!

      end{document}


      ranking stars with tikz





      And here's the much more elaborate, much more pointless, floating point scoring star macro (I'll leave the simple one in as well, it's a lot more usable):



      documentclass{article}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric,calc}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1em,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      pgfmathparse{(#1>int(#1)?int(#1+1):0}
      letpartstar=pgfmathresult
      ifnumpartstar>0
      pgfmathsetmacrostarpart{#1-(int(#1))}
      path [clip] ($(starpartstar.outer point 3)!(starpartstar.outer point 2)!(starpartstar.outer point 4)$) rectangle
      ($(starpartstar.outer point 2 |- starpartstar.outer point 1)!starpart!(starpartstar.outer point 1 -| starpartstar.outer point 5)$);
      fill (partstar*1em,0) node[scorestars,fill=yellow] {};
      fi

      ,end{tikzpicture}
      }

      begin{document}
      smallscore{2}{5} A meagre result.

      Huge{score{4.4}{5} Wooo!}

      end{document}


      enter image description here






      share|improve this answer


























      • Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

        – Matthew Leingang
        Feb 18 '11 at 16:06






      • 1





        Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

        – Loop Space
        Feb 18 '11 at 18:24











      • That is brilliant. Wow.

        – Robbie
        Feb 20 '11 at 12:11











      • One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

        – Robbie
        Feb 20 '11 at 12:18











      • @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

        – Jake
        Feb 20 '11 at 20:06














      49












      49








      49







      Here's the code for fully filled stars, now slightly improved thanks to Andrew Stacey's answer to the checkerboard question:



      documentclass{minimal}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1.75ex,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      end{tikzpicture}
      }

      begin{document}
      score{0}{5} A meagre result.

      score{4}{5} Much better

      score{5}{5} Perfect score!

      end{document}


      ranking stars with tikz





      And here's the much more elaborate, much more pointless, floating point scoring star macro (I'll leave the simple one in as well, it's a lot more usable):



      documentclass{article}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric,calc}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1em,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      pgfmathparse{(#1>int(#1)?int(#1+1):0}
      letpartstar=pgfmathresult
      ifnumpartstar>0
      pgfmathsetmacrostarpart{#1-(int(#1))}
      path [clip] ($(starpartstar.outer point 3)!(starpartstar.outer point 2)!(starpartstar.outer point 4)$) rectangle
      ($(starpartstar.outer point 2 |- starpartstar.outer point 1)!starpart!(starpartstar.outer point 1 -| starpartstar.outer point 5)$);
      fill (partstar*1em,0) node[scorestars,fill=yellow] {};
      fi

      ,end{tikzpicture}
      }

      begin{document}
      smallscore{2}{5} A meagre result.

      Huge{score{4.4}{5} Wooo!}

      end{document}


      enter image description here






      share|improve this answer















      Here's the code for fully filled stars, now slightly improved thanks to Andrew Stacey's answer to the checkerboard question:



      documentclass{minimal}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1.75ex,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      end{tikzpicture}
      }

      begin{document}
      score{0}{5} A meagre result.

      score{4}{5} Much better

      score{5}{5} Perfect score!

      end{document}


      ranking stars with tikz





      And here's the much more elaborate, much more pointless, floating point scoring star macro (I'll leave the simple one in as well, it's a lot more usable):



      documentclass{article}
      usepackage{tikz}
      usetikzlibrary{shapes.geometric,calc}

      newcommandscore[2]{
      pgfmathsetmacropgfxa{#1+1}
      tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=0.15em,anchor=outer point 3]
      begin{tikzpicture}[baseline]
      foreach i in {1,...,#2} {
      pgfmathparse{(i<=#1?"yellow":"gray")}
      edefstarcolor{pgfmathresult}
      draw (i*1em,0) node[name=stari,scorestars,fill=starcolor] {};
      }
      pgfmathparse{(#1>int(#1)?int(#1+1):0}
      letpartstar=pgfmathresult
      ifnumpartstar>0
      pgfmathsetmacrostarpart{#1-(int(#1))}
      path [clip] ($(starpartstar.outer point 3)!(starpartstar.outer point 2)!(starpartstar.outer point 4)$) rectangle
      ($(starpartstar.outer point 2 |- starpartstar.outer point 1)!starpart!(starpartstar.outer point 1 -| starpartstar.outer point 5)$);
      fill (partstar*1em,0) node[scorestars,fill=yellow] {};
      fi

      ,end{tikzpicture}
      }

      begin{document}
      smallscore{2}{5} A meagre result.

      Huge{score{4.4}{5} Wooo!}

      end{document}


      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 13 '17 at 12:36









      Community

      1




      1










      answered Feb 18 '11 at 9:59









      JakeJake

      195k24653762




      195k24653762













      • Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

        – Matthew Leingang
        Feb 18 '11 at 16:06






      • 1





        Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

        – Loop Space
        Feb 18 '11 at 18:24











      • That is brilliant. Wow.

        – Robbie
        Feb 20 '11 at 12:11











      • One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

        – Robbie
        Feb 20 '11 at 12:18











      • @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

        – Jake
        Feb 20 '11 at 20:06



















      • Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

        – Matthew Leingang
        Feb 18 '11 at 16:06






      • 1





        Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

        – Loop Space
        Feb 18 '11 at 18:24











      • That is brilliant. Wow.

        – Robbie
        Feb 20 '11 at 12:11











      • One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

        – Robbie
        Feb 20 '11 at 12:18











      • @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

        – Jake
        Feb 20 '11 at 20:06

















      Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

      – Matthew Leingang
      Feb 18 '11 at 16:06





      Like I said, very good (even better since I first said it). I didn't realize coordinates could be averaged with the ! like colors can. I had been going for a style approach so that you could type node[scorestars,portion=0.25] and get 25% of the star filled. Looks like you could use the append after command key for that.

      – Matthew Leingang
      Feb 18 '11 at 16:06




      1




      1





      Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

      – Loop Space
      Feb 18 '11 at 18:24





      Blast, I've already voted for this before your edit. I think that the floating point version is fantastic.

      – Loop Space
      Feb 18 '11 at 18:24













      That is brilliant. Wow.

      – Robbie
      Feb 20 '11 at 12:11





      That is brilliant. Wow.

      – Robbie
      Feb 20 '11 at 12:11













      One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

      – Robbie
      Feb 20 '11 at 12:18





      One question though: is it possible to make the stars scale to the text height? So if the text is large the stars will also be correspondingly bigger?

      – Robbie
      Feb 20 '11 at 12:18













      @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

      – Jake
      Feb 20 '11 at 20:06





      @zoqaeski: Done! Just use relative lengths ("ex" and "em") for the size and spacing.

      – Jake
      Feb 20 '11 at 20:06











      14














      enter image description here



      Asymptote version stars.asy:



      size(200);
      real sc=20;

      picture score(real scoreMark=0,guide star=scale(sc)*unitcircle, int maxscore=5,
      pen linePen=nullpen, pen bgPen=darkblue, pen scorePen=orange){
      picture pic;
      guide[] g;
      for(int i=0;i<maxscore;++i){
      g.push(shift((2sc*i,0))*star);
      }
      assert(maxscore>0 && scoreMark>=0 && scoreMark<=maxscore,"***** Wrong score.");
      fill(pic,box((-sc,-sc),(maxscore*2sc-sc,sc)),bgPen);
      fill(pic,box((-sc,-sc),(scoreMark*2sc-sc,sc)),scorePen);
      clip(pic,g);
      draw(pic,g,linePen);
      return pic;
      }

      guide star;
      pair p;
      for(int i=0;i<5;++i){
      p=rotate(72*i)*N;
      star=star--p;
      star=star--(scale(0.382)*rotate(72*i+36)*N);
      }
      star=scale(sc)*(star--cycle);

      add(score(scoreMark=1,star,maxscore=7),(0,0));
      add(score(scoreMark=2,star,maxscore=7,linePen=lightred,bgPen=lightblue),(0,-3sc));
      add(score(scoreMark=3.5,star,maxscore=5,linePen=lightred,bgPen=lightblue),(0,-6sc));
      add(score(scoreMark=3.75,star,maxscore=4,linePen=olive,bgPen=white,scorePen=lightgreen),(0,-9sc));

      add(score(4.2,bgPen=green+opacity(0.3),scorePen=red+opacity(0.5)),(0,3sc));


      To get a standalone stars.pdf run asy -f pdf stars.asy.






      share|improve this answer




























        14














        enter image description here



        Asymptote version stars.asy:



        size(200);
        real sc=20;

        picture score(real scoreMark=0,guide star=scale(sc)*unitcircle, int maxscore=5,
        pen linePen=nullpen, pen bgPen=darkblue, pen scorePen=orange){
        picture pic;
        guide[] g;
        for(int i=0;i<maxscore;++i){
        g.push(shift((2sc*i,0))*star);
        }
        assert(maxscore>0 && scoreMark>=0 && scoreMark<=maxscore,"***** Wrong score.");
        fill(pic,box((-sc,-sc),(maxscore*2sc-sc,sc)),bgPen);
        fill(pic,box((-sc,-sc),(scoreMark*2sc-sc,sc)),scorePen);
        clip(pic,g);
        draw(pic,g,linePen);
        return pic;
        }

        guide star;
        pair p;
        for(int i=0;i<5;++i){
        p=rotate(72*i)*N;
        star=star--p;
        star=star--(scale(0.382)*rotate(72*i+36)*N);
        }
        star=scale(sc)*(star--cycle);

        add(score(scoreMark=1,star,maxscore=7),(0,0));
        add(score(scoreMark=2,star,maxscore=7,linePen=lightred,bgPen=lightblue),(0,-3sc));
        add(score(scoreMark=3.5,star,maxscore=5,linePen=lightred,bgPen=lightblue),(0,-6sc));
        add(score(scoreMark=3.75,star,maxscore=4,linePen=olive,bgPen=white,scorePen=lightgreen),(0,-9sc));

        add(score(4.2,bgPen=green+opacity(0.3),scorePen=red+opacity(0.5)),(0,3sc));


        To get a standalone stars.pdf run asy -f pdf stars.asy.






        share|improve this answer


























          14












          14








          14







          enter image description here



          Asymptote version stars.asy:



          size(200);
          real sc=20;

          picture score(real scoreMark=0,guide star=scale(sc)*unitcircle, int maxscore=5,
          pen linePen=nullpen, pen bgPen=darkblue, pen scorePen=orange){
          picture pic;
          guide[] g;
          for(int i=0;i<maxscore;++i){
          g.push(shift((2sc*i,0))*star);
          }
          assert(maxscore>0 && scoreMark>=0 && scoreMark<=maxscore,"***** Wrong score.");
          fill(pic,box((-sc,-sc),(maxscore*2sc-sc,sc)),bgPen);
          fill(pic,box((-sc,-sc),(scoreMark*2sc-sc,sc)),scorePen);
          clip(pic,g);
          draw(pic,g,linePen);
          return pic;
          }

          guide star;
          pair p;
          for(int i=0;i<5;++i){
          p=rotate(72*i)*N;
          star=star--p;
          star=star--(scale(0.382)*rotate(72*i+36)*N);
          }
          star=scale(sc)*(star--cycle);

          add(score(scoreMark=1,star,maxscore=7),(0,0));
          add(score(scoreMark=2,star,maxscore=7,linePen=lightred,bgPen=lightblue),(0,-3sc));
          add(score(scoreMark=3.5,star,maxscore=5,linePen=lightred,bgPen=lightblue),(0,-6sc));
          add(score(scoreMark=3.75,star,maxscore=4,linePen=olive,bgPen=white,scorePen=lightgreen),(0,-9sc));

          add(score(4.2,bgPen=green+opacity(0.3),scorePen=red+opacity(0.5)),(0,3sc));


          To get a standalone stars.pdf run asy -f pdf stars.asy.






          share|improve this answer













          enter image description here



          Asymptote version stars.asy:



          size(200);
          real sc=20;

          picture score(real scoreMark=0,guide star=scale(sc)*unitcircle, int maxscore=5,
          pen linePen=nullpen, pen bgPen=darkblue, pen scorePen=orange){
          picture pic;
          guide[] g;
          for(int i=0;i<maxscore;++i){
          g.push(shift((2sc*i,0))*star);
          }
          assert(maxscore>0 && scoreMark>=0 && scoreMark<=maxscore,"***** Wrong score.");
          fill(pic,box((-sc,-sc),(maxscore*2sc-sc,sc)),bgPen);
          fill(pic,box((-sc,-sc),(scoreMark*2sc-sc,sc)),scorePen);
          clip(pic,g);
          draw(pic,g,linePen);
          return pic;
          }

          guide star;
          pair p;
          for(int i=0;i<5;++i){
          p=rotate(72*i)*N;
          star=star--p;
          star=star--(scale(0.382)*rotate(72*i+36)*N);
          }
          star=scale(sc)*(star--cycle);

          add(score(scoreMark=1,star,maxscore=7),(0,0));
          add(score(scoreMark=2,star,maxscore=7,linePen=lightred,bgPen=lightblue),(0,-3sc));
          add(score(scoreMark=3.5,star,maxscore=5,linePen=lightred,bgPen=lightblue),(0,-6sc));
          add(score(scoreMark=3.75,star,maxscore=4,linePen=olive,bgPen=white,scorePen=lightgreen),(0,-9sc));

          add(score(4.2,bgPen=green+opacity(0.3),scorePen=red+opacity(0.5)),(0,3sc));


          To get a standalone stars.pdf run asy -f pdf stars.asy.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 14 '13 at 16:23









          g.kovg.kov

          17.4k13976




          17.4k13976























              11














              With PSTricks.



              enter image description here



              documentclass[preview,border=12pt,varwidth]{standalone}
              usepackage{pstricks}
              usepackage{multido}
              SpecialCoor
              makeatletter
              defLoadPSVars{pstVerb{/ptcm {pst@numberpsunit div} bind def}}
              makeatother

              defpoints{}
              defStar{%
              xdefpoints{}% cleaning
              multido{iR=0+72,ir=36+72}{5}{xdefpoints{points (10pt;iR)(5pt;ir)}}
              expandafterpspolygonpoints}

              defRating#1{% #1: percentage
              psscalebox{0.35}{%
              begin{pspicture}(11pt,-11pt)(111pt,11pt)
              LoadPSVars
              psclip{pscustom{psLoop{5}{translate(20pt,0)Star}}}
              psframe*[linecolor=yellow](11pt,-11pt)(!#1 11 add ptcm 11 ptcm)
              endpsclip
              pscustom{psLoop{5}{translate(20pt,0)Star}}
              end{pspicture}}}

              begin{document}
              begin{enumerate}
              item Rating{100} PSTricks
              item Rating{50} Asymptote
              item Rating{20} Metapost
              item Rating{5} TikZ
              end{enumerate}
              end{document}


              Warning:





              • rput will not work inside pscustom. Use translate instead!


              • standalone discards my ptcm operator defined in the preamble, so I have to load it manually inside pspicture. It is sad!






              share|improve this answer





















              • 2





                TikZ, I am sorry. It is just an example!

                – kiss my armpit
                Apr 14 '13 at 10:02











              • @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

                – Black Mild
                Nov 20 '18 at 17:26
















              11














              With PSTricks.



              enter image description here



              documentclass[preview,border=12pt,varwidth]{standalone}
              usepackage{pstricks}
              usepackage{multido}
              SpecialCoor
              makeatletter
              defLoadPSVars{pstVerb{/ptcm {pst@numberpsunit div} bind def}}
              makeatother

              defpoints{}
              defStar{%
              xdefpoints{}% cleaning
              multido{iR=0+72,ir=36+72}{5}{xdefpoints{points (10pt;iR)(5pt;ir)}}
              expandafterpspolygonpoints}

              defRating#1{% #1: percentage
              psscalebox{0.35}{%
              begin{pspicture}(11pt,-11pt)(111pt,11pt)
              LoadPSVars
              psclip{pscustom{psLoop{5}{translate(20pt,0)Star}}}
              psframe*[linecolor=yellow](11pt,-11pt)(!#1 11 add ptcm 11 ptcm)
              endpsclip
              pscustom{psLoop{5}{translate(20pt,0)Star}}
              end{pspicture}}}

              begin{document}
              begin{enumerate}
              item Rating{100} PSTricks
              item Rating{50} Asymptote
              item Rating{20} Metapost
              item Rating{5} TikZ
              end{enumerate}
              end{document}


              Warning:





              • rput will not work inside pscustom. Use translate instead!


              • standalone discards my ptcm operator defined in the preamble, so I have to load it manually inside pspicture. It is sad!






              share|improve this answer





















              • 2





                TikZ, I am sorry. It is just an example!

                – kiss my armpit
                Apr 14 '13 at 10:02











              • @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

                – Black Mild
                Nov 20 '18 at 17:26














              11












              11








              11







              With PSTricks.



              enter image description here



              documentclass[preview,border=12pt,varwidth]{standalone}
              usepackage{pstricks}
              usepackage{multido}
              SpecialCoor
              makeatletter
              defLoadPSVars{pstVerb{/ptcm {pst@numberpsunit div} bind def}}
              makeatother

              defpoints{}
              defStar{%
              xdefpoints{}% cleaning
              multido{iR=0+72,ir=36+72}{5}{xdefpoints{points (10pt;iR)(5pt;ir)}}
              expandafterpspolygonpoints}

              defRating#1{% #1: percentage
              psscalebox{0.35}{%
              begin{pspicture}(11pt,-11pt)(111pt,11pt)
              LoadPSVars
              psclip{pscustom{psLoop{5}{translate(20pt,0)Star}}}
              psframe*[linecolor=yellow](11pt,-11pt)(!#1 11 add ptcm 11 ptcm)
              endpsclip
              pscustom{psLoop{5}{translate(20pt,0)Star}}
              end{pspicture}}}

              begin{document}
              begin{enumerate}
              item Rating{100} PSTricks
              item Rating{50} Asymptote
              item Rating{20} Metapost
              item Rating{5} TikZ
              end{enumerate}
              end{document}


              Warning:





              • rput will not work inside pscustom. Use translate instead!


              • standalone discards my ptcm operator defined in the preamble, so I have to load it manually inside pspicture. It is sad!






              share|improve this answer















              With PSTricks.



              enter image description here



              documentclass[preview,border=12pt,varwidth]{standalone}
              usepackage{pstricks}
              usepackage{multido}
              SpecialCoor
              makeatletter
              defLoadPSVars{pstVerb{/ptcm {pst@numberpsunit div} bind def}}
              makeatother

              defpoints{}
              defStar{%
              xdefpoints{}% cleaning
              multido{iR=0+72,ir=36+72}{5}{xdefpoints{points (10pt;iR)(5pt;ir)}}
              expandafterpspolygonpoints}

              defRating#1{% #1: percentage
              psscalebox{0.35}{%
              begin{pspicture}(11pt,-11pt)(111pt,11pt)
              LoadPSVars
              psclip{pscustom{psLoop{5}{translate(20pt,0)Star}}}
              psframe*[linecolor=yellow](11pt,-11pt)(!#1 11 add ptcm 11 ptcm)
              endpsclip
              pscustom{psLoop{5}{translate(20pt,0)Star}}
              end{pspicture}}}

              begin{document}
              begin{enumerate}
              item Rating{100} PSTricks
              item Rating{50} Asymptote
              item Rating{20} Metapost
              item Rating{5} TikZ
              end{enumerate}
              end{document}


              Warning:





              • rput will not work inside pscustom. Use translate instead!


              • standalone discards my ptcm operator defined in the preamble, so I have to load it manually inside pspicture. It is sad!







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Apr 14 '13 at 4:57

























              answered Apr 14 '13 at 4:46









              kiss my armpitkiss my armpit

              13.1k20174405




              13.1k20174405








              • 2





                TikZ, I am sorry. It is just an example!

                – kiss my armpit
                Apr 14 '13 at 10:02











              • @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

                – Black Mild
                Nov 20 '18 at 17:26














              • 2





                TikZ, I am sorry. It is just an example!

                – kiss my armpit
                Apr 14 '13 at 10:02











              • @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

                – Black Mild
                Nov 20 '18 at 17:26








              2




              2





              TikZ, I am sorry. It is just an example!

              – kiss my armpit
              Apr 14 '13 at 10:02





              TikZ, I am sorry. It is just an example!

              – kiss my armpit
              Apr 14 '13 at 10:02













              @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

              – Black Mild
              Nov 20 '18 at 17:26





              @armpit: do you still keep that opinion (100 PSTricks, 50 Asymptote, 20 Metapost, 5 TikZ)? ^^

              – Black Mild
              Nov 20 '18 at 17:26











              10














              I have written a package for ConTeXt that draws X out of Y graphics. It is primarily meant to draw numbers in presentations. It offers stars as one of the options:



              enter image description here



              usemodule[visualcounter]

              definepalet
              [star-colors]
              [active=yellow,
              past=yellow,
              future=gray]

              definevisualcounter
              [stars]
              [markers]
              [mpsetups=visualcounter::markers:star,
              width=1.5EmWidth,
              distance=0.25EmWidth,
              palette=star-colors,
              ]

              starttext

              startTEXpage[offset=2mm]
              startitemize
              item usevisualcounter[n=1, last=5]{stars} That's appalling!
              item usevisualcounter[n=2, last=5]{stars} A meagre result.
              item usevisualcounter[n=4, last=5]{stars} Woo!
              stopitemize
              stopTEXpage
              stoptext


              See documentation for more details.



              As the primary purpose of this module is to display page numbers, it does not support fractional values.






              share|improve this answer




























                10














                I have written a package for ConTeXt that draws X out of Y graphics. It is primarily meant to draw numbers in presentations. It offers stars as one of the options:



                enter image description here



                usemodule[visualcounter]

                definepalet
                [star-colors]
                [active=yellow,
                past=yellow,
                future=gray]

                definevisualcounter
                [stars]
                [markers]
                [mpsetups=visualcounter::markers:star,
                width=1.5EmWidth,
                distance=0.25EmWidth,
                palette=star-colors,
                ]

                starttext

                startTEXpage[offset=2mm]
                startitemize
                item usevisualcounter[n=1, last=5]{stars} That's appalling!
                item usevisualcounter[n=2, last=5]{stars} A meagre result.
                item usevisualcounter[n=4, last=5]{stars} Woo!
                stopitemize
                stopTEXpage
                stoptext


                See documentation for more details.



                As the primary purpose of this module is to display page numbers, it does not support fractional values.






                share|improve this answer


























                  10












                  10








                  10







                  I have written a package for ConTeXt that draws X out of Y graphics. It is primarily meant to draw numbers in presentations. It offers stars as one of the options:



                  enter image description here



                  usemodule[visualcounter]

                  definepalet
                  [star-colors]
                  [active=yellow,
                  past=yellow,
                  future=gray]

                  definevisualcounter
                  [stars]
                  [markers]
                  [mpsetups=visualcounter::markers:star,
                  width=1.5EmWidth,
                  distance=0.25EmWidth,
                  palette=star-colors,
                  ]

                  starttext

                  startTEXpage[offset=2mm]
                  startitemize
                  item usevisualcounter[n=1, last=5]{stars} That's appalling!
                  item usevisualcounter[n=2, last=5]{stars} A meagre result.
                  item usevisualcounter[n=4, last=5]{stars} Woo!
                  stopitemize
                  stopTEXpage
                  stoptext


                  See documentation for more details.



                  As the primary purpose of this module is to display page numbers, it does not support fractional values.






                  share|improve this answer













                  I have written a package for ConTeXt that draws X out of Y graphics. It is primarily meant to draw numbers in presentations. It offers stars as one of the options:



                  enter image description here



                  usemodule[visualcounter]

                  definepalet
                  [star-colors]
                  [active=yellow,
                  past=yellow,
                  future=gray]

                  definevisualcounter
                  [stars]
                  [markers]
                  [mpsetups=visualcounter::markers:star,
                  width=1.5EmWidth,
                  distance=0.25EmWidth,
                  palette=star-colors,
                  ]

                  starttext

                  startTEXpage[offset=2mm]
                  startitemize
                  item usevisualcounter[n=1, last=5]{stars} That's appalling!
                  item usevisualcounter[n=2, last=5]{stars} A meagre result.
                  item usevisualcounter[n=4, last=5]{stars} Woo!
                  stopitemize
                  stopTEXpage
                  stoptext


                  See documentation for more details.



                  As the primary purpose of this module is to display page numbers, it does not support fractional values.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 14 '13 at 1:43









                  AdityaAditya

                  55.6k2110236




                  55.6k2110236























                      6














                      Jake's answer is very good. Here's the extra half star:



                      node[scorestars,fill=gray] {};
                      path node[scorestars,fill=yellow] (s) {} [clip] (s.south west) rectangle (s.north);





                      share|improve this answer



















                      • 1





                        ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

                        – Loop Space
                        Feb 18 '11 at 13:07











                      • @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

                        – Hendrik Vogt
                        Feb 18 '11 at 13:15











                      • @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

                        – Matthew Leingang
                        Feb 18 '11 at 13:44






                      • 1





                        @Matthew: Consider yourself asked.

                        – Loop Space
                        Feb 18 '11 at 13:47






                      • 3





                        @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

                        – Matthew Leingang
                        Feb 18 '11 at 16:00
















                      6














                      Jake's answer is very good. Here's the extra half star:



                      node[scorestars,fill=gray] {};
                      path node[scorestars,fill=yellow] (s) {} [clip] (s.south west) rectangle (s.north);





                      share|improve this answer



















                      • 1





                        ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

                        – Loop Space
                        Feb 18 '11 at 13:07











                      • @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

                        – Hendrik Vogt
                        Feb 18 '11 at 13:15











                      • @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

                        – Matthew Leingang
                        Feb 18 '11 at 13:44






                      • 1





                        @Matthew: Consider yourself asked.

                        – Loop Space
                        Feb 18 '11 at 13:47






                      • 3





                        @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

                        – Matthew Leingang
                        Feb 18 '11 at 16:00














                      6












                      6








                      6







                      Jake's answer is very good. Here's the extra half star:



                      node[scorestars,fill=gray] {};
                      path node[scorestars,fill=yellow] (s) {} [clip] (s.south west) rectangle (s.north);





                      share|improve this answer













                      Jake's answer is very good. Here's the extra half star:



                      node[scorestars,fill=gray] {};
                      path node[scorestars,fill=yellow] (s) {} [clip] (s.south west) rectangle (s.north);






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 18 '11 at 13:01









                      Matthew LeingangMatthew Leingang

                      35.2k10107178




                      35.2k10107178








                      • 1





                        ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

                        – Loop Space
                        Feb 18 '11 at 13:07











                      • @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

                        – Hendrik Vogt
                        Feb 18 '11 at 13:15











                      • @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

                        – Matthew Leingang
                        Feb 18 '11 at 13:44






                      • 1





                        @Matthew: Consider yourself asked.

                        – Loop Space
                        Feb 18 '11 at 13:47






                      • 3





                        @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

                        – Matthew Leingang
                        Feb 18 '11 at 16:00














                      • 1





                        ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

                        – Loop Space
                        Feb 18 '11 at 13:07











                      • @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

                        – Hendrik Vogt
                        Feb 18 '11 at 13:15











                      • @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

                        – Matthew Leingang
                        Feb 18 '11 at 13:44






                      • 1





                        @Matthew: Consider yourself asked.

                        – Loop Space
                        Feb 18 '11 at 13:47






                      • 3





                        @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

                        – Matthew Leingang
                        Feb 18 '11 at 16:00








                      1




                      1





                      ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

                      – Loop Space
                      Feb 18 '11 at 13:07





                      ... and here's half a vote. Oh, wait, they don't come in half steps yet so you'll have to have a whole one. (Incidentally, why isn't your name in the list of moderator candidates?)

                      – Loop Space
                      Feb 18 '11 at 13:07













                      @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

                      – Hendrik Vogt
                      Feb 18 '11 at 13:15





                      @Matthew: Can you please tell a TikZ noob how to include this into Jake's code?

                      – Hendrik Vogt
                      Feb 18 '11 at 13:15













                      @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

                      – Matthew Leingang
                      Feb 18 '11 at 13:44





                      @Andrew: LOL. I only gave half an answer hoping that Jake could run with it and improve his answer. I already spent an hour trying to make a customizable portion of the star filled so I think I should quit for now.

                      – Matthew Leingang
                      Feb 18 '11 at 13:44




                      1




                      1





                      @Matthew: Consider yourself asked.

                      – Loop Space
                      Feb 18 '11 at 13:47





                      @Matthew: Consider yourself asked.

                      – Loop Space
                      Feb 18 '11 at 13:47




                      3




                      3





                      @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

                      – Matthew Leingang
                      Feb 18 '11 at 16:00





                      @Jake: True that. look at the bright side. You've got 70 rep so far out of it. That and $2.25 will buy you a cup of coffee at Starbucks.

                      – Matthew Leingang
                      Feb 18 '11 at 16:00


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f11390%2fdrawing-stars-similar-with-tikz%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Why does my Macbook overheat and use so much CPU and energy when on YouTube?Why do so many insist on using...

                      How to prevent page numbers from appearing on glossaries?How to remove a dot and a page number in the...

                      Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...