def drawFrontFacePair(topCorners, bottomCorners, color): pointList = [] pointList2 = [] output = G() YZStyle1 = StyleBuilder() #YZStyle1.setStroke('black') #YZStyle1.setStrokeWidth(1.5) YZStyle1.setFilling(color) YZStyle1.setFillOpacity(0.75) YZStyle2 = StyleBuilder() YZStyle2.setStroke('black') YZStyle2.setStrokeWidth(0.5) YZStyle2.setFillOpacity(0.75) YZStyle2.setFilling('#ffffff') pointList.append(strPathStart(topCorners[1])) pointList.append(strPathPoint(topCorners[2])) pointList.append(strPathPoint(bottomCorners[2])) pointList.append(strPathPoint(bottomCorners[1])) svgCode1 = pGram(pointList) pointList2.append(strPathStart(topCorners[0])) pointList2.append(strPathPoint(topCorners[3])) pointList2.append(strPathPoint(bottomCorners[3])) pointList2.append(strPathPoint(bottomCorners[0])) svgCode2 = pGram(pointList2) frontFace = Path(svgCode1) frontFace.set_style(YZStyle1.getStyle()) backFace = Path(svgCode2) backFace.set_style(YZStyle2.getStyle()) output.addElement(backFace) output.addElement(frontFace) return output
def draw(self): faceStyle = StyleBuilder() faceStyle.setFilling('blue') faceStyle.setStroke('black') faceStyle.setFillOpacity(0.5) topStyle = StyleBuilder() topStyle.setFilling('green') topStyle.setStroke('black') topStyle.setStrokeWidth(2) topStyle.setFillOpacity(0.5) sideStyle = StyleBuilder() sideStyle.setFilling('red') sideStyle.setStroke('black') sideStyle.setStrokeWidth(2) sideStyle.setFillOpacity(0.5) frontFace = Rect(self.startCoord[0], self.startCoord[1], self.x, self.z) backFace = Rect(self.startCoord[0] + self.y/math.sqrt(2), self.startCoord[1] - self.y/math.sqrt(2), self.x, self.z) # draw parallelogram, grab corners cornerBack = backFace.getEdgePoints() cornerFront = frontFace.getEdgePoints() # Top face string pointListT = [] pointListT.append(strPathStart(cornerBack[0])) pointListT.append(strPathPoint(cornerBack[1])) pointListT.append(strPathPoint(cornerFront[1])) pointListT.append(strPathPoint(cornerFront[0])) topFaceString = pGram(pointListT) # right side face pointListR = [strPathStart(cornerBack[1])] pointListR.append(strPathPoint(cornerBack[2])) pointListR.append(strPathPoint(cornerFront[2])) pointListR.append(strPathPoint(cornerFront[1])) # bottom face pointListB = [strPathStart(cornerBack[2])] pointListB.append(strPathPoint(cornerBack[3])) pointListB.append(strPathPoint(cornerFront[3])) pointListB.append(strPathPoint(cornerFront[2])) # left pointListL = [strPathStart(cornerBack[0])] pointListL.append(strPathPoint(cornerBack[3])) pointListL.append(strPathPoint(cornerFront[3])) pointListL.append(strPathPoint(cornerFront[0])) # make faces topFace = Path(pGram(pointListT)) rightFace = Path(pGram(pointListR)) leftFace = Path(pGram(pointListL)) bottomFace = Path(pGram(pointListB)) topFace.set_style(topStyle.getStyle()) bottomFace.set_style(topStyle.getStyle()) rightFace.set_style(sideStyle.getStyle()) leftFace.set_style(sideStyle.getStyle()) frontFace.set_style(faceStyle.getStyle()) backFace.set_style(faceStyle.getStyle()) self.out.addElement(backFace) self.out.addElement(frontFace) self.out.addElement(rightFace) self.out.addElement(leftFace) self.out.addElement(bottomFace) self.out.addElement(topFace) return self.out