def rmoveto(self, dx, dy): r'''Postscript ``rmoveto`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.rmoveto(1, 1) >>> postscript = postscript.rlineto(3, -4) >>> postscript = postscript.stroke() >>> print(format(postscript)) markuptools.Postscript( operators=( markuptools.PostscriptOperator('rmoveto', 1.0, 1.0), markuptools.PostscriptOperator('rlineto', 3.0, -4.0), markuptools.PostscriptOperator('stroke'), ), ) :: >>> print(str(postscript)) 1 1 rmoveto 3 -4 rlineto stroke Returns new Postscript. ''' from abjad.tools import markuptools dx = float(dx) dy = float(dy) operator = markuptools.PostscriptOperator('rmoveto', dx, dy) return self._with_operator(operator)
def show(self, text): r'''Postscript ``show`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.findfont('Times Roman') >>> postscript = postscript.scalefont(12) >>> postscript = postscript.setfont() >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(100, 200) >>> postscript = postscript.show('This is text.') >>> print(str(postscript)) /Times-Roman findfont 12 scalefont setfont newpath 100 200 moveto (This is text.) show Returns new Postscript. ''' from abjad.tools import markuptools text = str(text) operator = markuptools.PostscriptOperator('show', text) return self._with_operator(operator)
def moveto(self, x, y): r'''Postscript ``moveto`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.moveto(1, 1) >>> postscript = postscript.lineto(3, -4) >>> postscript = postscript.stroke() >>> print(format(postscript)) markuptools.Postscript( operators=( markuptools.PostscriptOperator('moveto', 1.0, 1.0), markuptools.PostscriptOperator('lineto', 3.0, -4.0), markuptools.PostscriptOperator('stroke'), ), ) :: >>> print(str(postscript)) 1 1 moveto 3 -4 lineto stroke Returns new Postscript. ''' from abjad.tools import markuptools x = float(x) y = float(y) operator = markuptools.PostscriptOperator('moveto', x, y) return self._with_operator(operator)
def rcurveto(self, dx1, dy1, dx2, dy2, dx3, dy3): r'''Postscript ``rcurveto`` operator. .. container:: edxample :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.rcurveto(0, 1, 1.5, 2, 3, 6) >>> print(str(postscript)) 0 1 1.5 2 3 6 rcurveto Returns new Postscript. ''' from abjad.tools import markuptools dx1 = float(dx1) dx2 = float(dx2) dx3 = float(dx3) dy1 = float(dy1) dy2 = float(dy2) dy3 = float(dy3) operator = markuptools.PostscriptOperator( 'rcurveto', dx1, dy1, dx2, dy2, dx3, dy3, ) return self._with_operator(operator)
def curveto(self, x1, y1, x2, y2, x3, y3): r'''Postscript ``curveto`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.curveto(0, 1, 1.5, 2, 3, 6) >>> print(str(postscript)) 0 1 1.5 2 3 6 curveto Returns new Postscript. ''' from abjad.tools import markuptools x1 = float(x1) x2 = float(x2) x3 = float(x3) y1 = float(y1) y2 = float(y2) y3 = float(y3) operator = markuptools.PostscriptOperator( 'curveto', x1, y1, x2, y2, x3, y3, ) return self._with_operator(operator)
def findfont(self, font_name): r'''Postscript ``findfont`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.findfont('Times Roman') >>> postscript = postscript.scalefont(12) >>> postscript = postscript.setfont() >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(100, 200) >>> postscript = postscript.show('This is text.') >>> print(str(postscript)) /Times-Roman findfont 12 scalefont setfont newpath 100 200 moveto (This is text.) show Returns new Postscript. ''' from abjad.tools import markuptools font_name = str(font_name) font_name = font_name.replace(' ', '-') font_name = '/{}'.format(font_name) operator = markuptools.PostscriptOperator('findfont', font_name) return self._with_operator(operator)
def stroke(self): r'''Postscript ``stroke`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.lineto(3, -4) >>> postscript = postscript.stroke() >>> print(format(postscript)) markuptools.Postscript( operators=( markuptools.PostscriptOperator('lineto', 3.0, -4.0), markuptools.PostscriptOperator('stroke'), ), ) :: >>> print(str(postscript)) 3 -4 lineto stroke Returns new Postscript. ''' from abjad.tools import markuptools operator = markuptools.PostscriptOperator('stroke') return self._with_operator(operator)
def setlinewidth(self, width): r'''Postscript ``setlinewidth`` operator. .. container:: example >>> postscript = abjad.Postscript() >>> postscript = postscript.moveto(1, 1) >>> postscript = postscript.setlinewidth(2.5) >>> postscript = postscript.lineto(3, -4) >>> postscript = postscript.stroke() >>> print(format(postscript)) abjad.Postscript( operators=( abjad.PostscriptOperator('moveto', 1.0, 1.0), abjad.PostscriptOperator('setlinewidth', 2.5), abjad.PostscriptOperator('lineto', 3.0, -4.0), abjad.PostscriptOperator('stroke'), ), ) >>> print(str(postscript)) 1 1 moveto 2.5 setlinewidth 3 -4 lineto stroke Returns new Postscript. ''' from abjad.tools import markuptools width = float(width) operator = markuptools.PostscriptOperator('setlinewidth', width) return self._with_operator(operator)
def setrgbcolor(self, red, green, blue): r'''Postscript ``setrgb`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(100, 100) >>> postscript = postscript.rlineto(0, 100) >>> postscript = postscript.rlineto(100, 0) >>> postscript = postscript.rlineto(0, -100) >>> postscript = postscript.rlineto(-100, 0) >>> postscript = postscript.closepath() >>> postscript = postscript.gsave() >>> postscript = postscript.setrgbcolor(0.5, 1, 0.5) >>> postscript = postscript.fill() >>> postscript = postscript.grestore() >>> postscript = postscript.setrgbcolor(1, 0, 0) >>> postscript = postscript.setlinewidth(4) >>> postscript = postscript.stroke() :: >>> print(str(postscript)) newpath 100 100 moveto 0 100 rlineto 100 0 rlineto 0 -100 rlineto -100 0 rlineto closepath gsave 0.5 1 0.5 setrgbcolor fill grestore 1 0 0 setrgbcolor 4 setlinewidth stroke Returns new Postscript. ''' from abjad.tools import markuptools red = float(red) green = float(green) blue = float(blue) assert 0 <= red <= 1 assert 0 <= green <= 1 assert 0 <= blue <= 1 operator = markuptools.PostscriptOperator( 'setrgbcolor', red, green, blue, ) return self._with_operator(operator)
def setdash(self, array=None, offset=0): r'''Postscript ``setdash`` operator. .. container:: example :: >>> postscript = markuptools.Postscript().setdash([2, 1], 3) >>> print(format(postscript)) markuptools.Postscript( operators=( markuptools.PostscriptOperator('setdash', (2.0, 1.0), 3.0), ), ) :: >>> print(str(postscript)) [ 2 1 ] 3 setdash .. container:: example :: >>> postscript = markuptools.Postscript().setdash() >>> print(format(postscript)) markuptools.Postscript( operators=( markuptools.PostscriptOperator('setdash', (), 0.0), ), ) :: >>> print(str(postscript)) [ ] 0 setdash Returns new Postscript. ''' from abjad.tools import markuptools if array is None: array = () else: array = tuple(float(_) for _ in array) offset = float(offset) operator = markuptools.PostscriptOperator('setdash', array, offset) return self._with_operator(operator)
def charpath(self, text, modify_font=True): r'''Postscript ``charpath`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.findfont('Times Roman') >>> postscript = postscript.scalefont(32) >>> postscript = postscript.setfont() >>> postscript = postscript.translate(100, 200) >>> postscript = postscript.rotate(45) >>> postscript = postscript.scale(2, 1) >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(0, 0) >>> postscript = postscript.charpath('This is text.', True) >>> postscript = postscript.setlinewidth(0.5) >>> postscript = postscript.setgray(0.25) >>> postscript = postscript.stroke() >>> print(str(postscript)) /Times-Roman findfont 32 scalefont setfont 100 200 translate 45 rotate 2 1 scale newpath 0 0 moveto (This is text.) true charpath 0.5 setlinewidth 0.25 setgray stroke Returns new Postscript. ''' from abjad.tools import markuptools text = str(text) modify_font = bool(modify_font) operator = markuptools.PostscriptOperator( 'charpath', text, modify_font, ) return self._with_operator(operator)
def setgray(self, gray_value): r'''Postscript ``setgray`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(100, 200) >>> postscript = postscript.lineto(200, 250) >>> postscript = postscript.lineto(100, 300) >>> postscript = postscript.closepath() >>> postscript = postscript.gsave() >>> postscript = postscript.setgray(0.5) >>> postscript = postscript.fill() >>> postscript = postscript.grestore() >>> postscript = postscript.setlinewidth(4) >>> postscript = postscript.setgray(0.75) >>> postscript = postscript.stroke() >>> print(str(postscript)) newpath 100 200 moveto 200 250 lineto 100 300 lineto closepath gsave 0.5 setgray fill grestore 4 setlinewidth 0.75 setgray stroke Returns new Postscript. ''' from abjad.tools import markuptools gray_value = float(gray_value) assert 0 <= gray_value <= 1 operator = markuptools.PostscriptOperator('setgray', gray_value) return self._with_operator(operator)
def scale(self, dx, dy): r'''Postscript ``scale`` operator. .. container:: example :: >>> postscript = markuptools.Postscript() >>> postscript = postscript.findfont('Times Roman') >>> postscript = postscript.scalefont(32) >>> postscript = postscript.setfont() >>> postscript = postscript.translate(100, 200) >>> postscript = postscript.rotate(45) >>> postscript = postscript.scale(2, 1) >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(0, 0) >>> postscript = postscript.charpath('This is text.', True) >>> postscript = postscript.setlinewidth(0.5) >>> postscript = postscript.setgray(0.25) >>> postscript = postscript.stroke() >>> print(str(postscript)) /Times-Roman findfont 32 scalefont setfont 100 200 translate 45 rotate 2 1 scale newpath 0 0 moveto (This is text.) true charpath 0.5 setlinewidth 0.25 setgray stroke Returns new Postscript. ''' from abjad.tools import markuptools dx = float(dx) dy = float(dy) operator = markuptools.PostscriptOperator('scale', dx, dy) return self._with_operator(operator)
def lineto(self, x, y): r'''Postscript ``lineto`` operator. .. container:: example >>> postscript = abjad.Postscript() >>> postscript = postscript.moveto(1, 1) >>> postscript = postscript.lineto(3, -4) >>> postscript = postscript.stroke() >>> print(str(postscript)) 1 1 moveto 3 -4 lineto stroke Returns new Postscript. ''' from abjad.tools import markuptools x = float(x) y = float(y) operator = markuptools.PostscriptOperator('lineto', x, y) return self._with_operator(operator)
def newpath(self): r'''Postscript ``newpath`` operator. .. container:: example >>> postscript = abjad.Postscript() >>> postscript = postscript.newpath() >>> postscript = postscript.moveto(100, 200) >>> postscript = postscript.lineto(200, 250) >>> postscript = postscript.lineto(100, 300) >>> postscript = postscript.closepath() >>> postscript = postscript.gsave() >>> postscript = postscript.setgray(0.5) >>> postscript = postscript.fill() >>> postscript = postscript.grestore() >>> postscript = postscript.setlinewidth(4) >>> postscript = postscript.setgray(0.75) >>> postscript = postscript.stroke() >>> print(str(postscript)) newpath 100 200 moveto 200 250 lineto 100 300 lineto closepath gsave 0.5 setgray fill grestore 4 setlinewidth 0.75 setgray stroke Returns new Postscript. ''' from abjad.tools import markuptools operator = markuptools.PostscriptOperator('newpath') return self._with_operator(operator)