def updateSortValue(self): Shape.updateSortValue(self) if self.quarters != 4: return # ellipse is self closing, do not count last point twice length = len(self.pathCommands) lastPoint = self.pathCommands[length - 1].endRenderPoint self.sortValue -= lastPoint.z / length
def __init__(self, glyph, centered=True, **kwargs): self.glyph = glyph if centered: L, B, R, T = self.glyph.bounds x = L + (R - L) / 2 y = B + (T - B) / 2 kwargs['translate'] = {'x': -x, 'y': -y} Shape.__init__(self, **kwargs) self.updatePath()
def __init__(self, width=1, height=1, cornerRadius=0.25, closed=False, **kwargs): self.width = width if width is not None else 1 self.height = height if height is not None else 1 self.cornerRadius = cornerRadius self.closed = closed Shape.__init__(self, **kwargs)
def __init__(self, diameter=1, width=None, height=None, quarters=4, closed=False, **kwargs): self.diameter = diameter self.width = width self.height = height self.quarters = quarters self.closed = closed Shape.__init__(self, **kwargs)
def __init__(self, diameter=1, length=1, frontFace=True, backFace=True, fill=True, **kwargs): Shape.__init__(self, **kwargs) self.diameter = diameter self.length = length self.frontFace = frontFace self.backFace = backFace self.fill = fill self.group = CylinderGroup(addTo=self) # visible=self.visible, color=self.color baseZ = self.length / 2 baseColor = self.backface # if self.backface else True groupOptions = { 'addTo' : self.group, 'diameter' : self.diameter, 'color' : self.color, 'stroke' : self.stroke, 'fill' : self.fill, 'visible' : self.visible } # front outside base self.group.frontBase = Ellipse( translate={ 'z': baseZ }, rotate={ 'y': TAU / 2 }, backface=self.frontFace, # || baseColor, **groupOptions) # back outside base self.group.rearBase = Ellipse( translate={ 'z': -baseZ }, rotate={ 'y': 0 }, backface=baseColor, **groupOptions)
# read transform from attribute and set anchor anchorOptions = { 'addTo': I } anchor = Anchor(**anchorOptions) # circle Ellipse( addTo=anchor, diameter=80, translate={ 'z' : -40 }, stroke=20, color=eggplant, ) # triangle Shape( addTo=anchor, path=[ { 'x' : 0, 'y' : -32 }, { 'x' : 32, 'y' : 32 }, { 'x' : -32, 'y' : 32 }, ], translate={ 'z' : 40 }, color=orange, stroke=12, fill=True) I.showInterface() I.updateRenderGraph()
def __init__(self, width=None, height=None, **kwargs): self.width = width if width is not None else 1 self.height = height if height is not None else 1 Shape.__init__(self, **kwargs)
'depth': D, 'topFace': yellow, 'rearFace': gold, 'leftFace': orange, 'rightFace': orange, 'frontFace': garnet, 'bottomFace': eggplant, } Box(translate={'y': -D}, **boxOptions) # top # bottomFace=False Box(translate={'y': D}, **boxOptions) # bottom # topFace=False Box(translate={'z': D}, **boxOptions) # front # rearFace=False Box(translate={'z': -D}, **boxOptions) # back # frontFace Box(translate={'x': D}, **boxOptions) # left # rightFace=False Box(translate={'x': -D}, **boxOptions) # right # leftFace=False dotOptions = { 'addTo': model, 'stroke': D, } Shape(translate={'y': -D * 2}, color=gold, **dotOptions) Shape(translate={'y': D * 2}, color=gold, **dotOptions) Shape(translate={'x': -D * 2}, color=yellow, **dotOptions) Shape(translate={'x': D * 2}, color=garnet, **dotOptions) Shape(translate={'z': -D * 2}, color=orange, **dotOptions) Shape(translate={'z': D * 2}, color=eggplant, **dotOptions) I.showInterface() I.updateRenderGraph()
from zDogPy.vector import Vector from zDogPy.shape import Shape from zDogPy.illustration import Illustration I = Illustration() I.setSize(24, 24) D = 5 S = 3 origin = Anchor(addTo=I, scale=3) dotOptions = dict(addTo=origin, stroke=S, color=(1, 0, 0, 0.5)) # Shape(translate={ 'x': 0, 'y' : 0, 'z': 0 }, **dotOptions) Shape(translate={ 'x': D, 'y' : D, 'z': D }, **dotOptions) Shape(translate={ 'x': -D, 'y' : D, 'z': D }, **dotOptions) Shape(translate={ 'x': D, 'y' : -D, 'z': D }, **dotOptions) Shape(translate={ 'x': -D, 'y' : -D, 'z': D }, **dotOptions) Shape(translate={ 'x': 0, 'y' : D, 'z': D }, **dotOptions) Shape(translate={ 'x': 0, 'y' : -D, 'z': D }, **dotOptions) Shape(translate={ 'x': 0, 'y' : D, 'z': -D }, **dotOptions) Shape(translate={ 'x': 0, 'y' : -D, 'z': -D }, **dotOptions) Shape(translate={ 'x': D, 'y' : D, 'z': -D }, **dotOptions) Shape(translate={ 'x': -D, 'y' : D, 'z': -D }, **dotOptions) Shape(translate={ 'x': D, 'y' : -D, 'z': -D }, **dotOptions) Shape(translate={ 'x': -D, 'y' : -D, 'z': -D }, **dotOptions) Shape(translate={ 'x': D, 'y' : 0, 'z': -D }, **dotOptions)
def __init__(self, sides=3, radius=0.5, **kwargs): self.sides = sides self.radius = radius Shape.__init__(self, **kwargs)
def render(self, ctx, renderer): Shape.render(self, ctx, renderer)
start = {'x': -60, 'y': -60} startControl = {'x': 20, 'y': -60} endControl = {'x': -20, 'y': 60} end = {'x': 60, 'y': 60} I = Illustration() I.setSize(200, 200) # curve Shape( addTo=I, path=[ start, { 'bezier': [startControl, endControl, end] }, ], closed=False, stroke=20, color=eggplant, ) # control points controlDot = Shape( addTo=I, translate=startControl, stroke=12, color=orange, ) controlDot.copy(translate=endControl, )
I.setSize(60, 60) # lines S1 = Shape(addTo=I, path=[ { 'x': -6, 'y': -6 }, { 'x': 6, 'y': -6 }, { 'x': 6, 'y': 6 }, { 'x': -6, 'y': 6 }, ], translate={ 'x': -12, 'y': -12 }, closed=False, color=eggplant, stroke=2) # move S2 = Shape(addTo=I,