#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic


def deg(d):
    return (2 * maths.pi) * d / 360


p = pic(scale=2)

tau = 2 * maths.pi
bit = 0.1
tick = 0.05

### label
p.op().text((tau / 2, 1), "sine")

### axes
p.op().line((-bit, 0), (tau + bit, 0))
p.op().line((0, -(1 + bit)), (0, 1 + bit))

### axis ticks and labels
p.op().to_left().below().text((-tick, -tick), r"$0$")
p.op().line((tau / 4, -tick), (tau / 4, 0))
p.op().below().text((tau / 4, -tick), r"$\tau/4$")
Ejemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import pic, pypyx_maths

p = pic (scale = 0.25)

o_x = 10
o_y = 10
o = (o_x, o_y)

n = 20

for i in xrange (0, n+1):

	a = pypyx_maths.tau * i / n;
	a2 = a/2

	#print i, a2, a

	sx = o_x + (i + 2) * maths.cos(a2)
	sy = o_y + (i + 2) * maths.sin(a2)

	p.op().arc (o, (sx,sy), a)

p.output_pdf (os.path.splitext(__file__)[0])
Ejemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic


def deg(d):
    return (2 * maths.pi) * d / 360


p = pic(scale=2)

tau = 2 * maths.pi

p.op().dashed().smooth_poly_curve([
    (0, 0),
    (tau / 4, 1),
    (tau / 2, 0),
    (3 * tau / 4, -1),
    (tau, 0),
])

p.op().closed().smooth_poly_curve([
    (0, 0),
    (tau / 4, 1),
    (tau / 2, 0),
    (3 * tau / 4, -1),
Ejemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic

p = pic(scale=.15)

x = 0


def pos():
    global x
    x += 1
    return (0, x)


p.op().stroked(colour.red()).text(pos(), 'red')
p.op().stroked(colour.orange()).text(pos(), 'orange')
p.op().stroked(colour.yellow()).text(pos(), 'yellow')
p.op().stroked(colour.lime()).text(pos(), 'lime')
p.op().stroked(colour.green()).text(pos(), 'green')
p.op().stroked(colour.cyan()).text(pos(), 'cyan')
p.op().stroked(colour.blue()).text(pos(), 'blue')
p.op().stroked(colour.magenta()).text(pos(), 'magenta')
p.op().stroked(colour.white()).text(pos(), 'white')
p.op().stroked(colour.black()).text(pos(), 'black')
Ejemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic

p = pic (scale = 4.0)

r2 = maths.sqrt(2)

o = (0, 0)
x = (r2, 0)
y = (0, 1)
xy = (r2, 1)

p.op().stroked(colour.light_grey()).circle ((r2/2, 1/2), maths.sqrt(3) / 2)

p.op().dotted().line (o, x)
p.op().stroked('blue').line (o, y)
p.op().styled('dashed red').line (y, xy)
p.op().line (x, xy)

p.op().text ((r2/2, 1/2), 'A4')

p.output_pdf (os.path.splitext(__file__)[0])
Ejemplo n.º 6
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import pic, pypyx_maths

p = pic(scale=0.25)

o_x = 10
o_y = 10
o = (o_x, o_y)

n = 20

for i in xrange(0, n + 1):

    a = pypyx_maths.tau * i / n
    a2 = a / 2

    #print i, a2, a

    sx = o_x + (i + 2) * maths.cos(a2)
    sy = o_y + (i + 2) * maths.sin(a2)

    p.op().arc(o, (sx, sy), a)

p.output_pdf(os.path.splitext(__file__)[0])
Ejemplo n.º 7
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic

p = pic(scale=4.0)

r2 = maths.sqrt(2)

o = (0, 0)
x = (r2, 0)
y = (0, 1)
xy = (r2, 1)

p.op().stroked(colour.light_grey()).circle((r2 / 2, 1 / 2), maths.sqrt(3) / 2)

p.op().dotted().line(o, x)
p.op().stroked('blue').line(o, y)
p.op().styled('dashed red').line(y, xy)
p.op().line(x, xy)

p.op().text((r2 / 2, 1 / 2), 'A4')

p.output_pdf(os.path.splitext(__file__)[0])
Ejemplo n.º 8
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic

p = pic (scale = .15)

x = 0

def pos ():
	global x
	x += 1
	return (0, x)

p.op().stroked(colour.red()).text (pos(), 'red')
p.op().stroked(colour.orange()).text (pos(), 'orange')
p.op().stroked(colour.yellow()).text (pos(), 'yellow')
p.op().stroked(colour.lime()).text (pos(),'lime')
p.op().stroked(colour.green()).text (pos(), 'green')
p.op().stroked(colour.cyan()).text (pos(), 'cyan')
p.op().stroked(colour.blue()).text (pos(), 'blue')
p.op().stroked(colour.magenta()).text (pos(), 'magenta')
p.op().stroked(colour.white()).text (pos(), 'white')
p.op().stroked(colour.black()).text (pos(), 'black')

p.op().stroked(colour.purple()).text (pos(), 'purple')
p.op().stroked(colour.brown()).text (pos(), 'brown')
Ejemplo n.º 9
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic

p = pic (scale = 1)

num_pts = 5
step = 2
r = 0.5

tau = 2 * maths.pi
pts = []

for idx in xrange(0, num_pts):
	a = tau * idx * step / num_pts
	x = r * maths.sin(a)
	y = r * maths.cos(a)

	pts.append ((x, y))

p.op().parity_winding().filled(colour.grey(0.5)).closed().poly_line (
		pts
	)

p.output_pdf (os.path.splitext(__file__)[0])
Ejemplo n.º 10
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import division

import math as maths
import os
from pypyx.pypyx import colour, pic

p = pic(scale=1)

num_pts = 5
step = 2
r = 0.5

tau = 2 * maths.pi
pts = []

for idx in xrange(0, num_pts):
    a = tau * idx * step / num_pts
    x = r * maths.sin(a)
    y = r * maths.cos(a)

    pts.append((x, y))

p.op().parity_winding().filled(colour.grey(0.5)).closed().poly_line(pts)

p.output_pdf(os.path.splitext(__file__)[0])