def rev_path(x1,y1, x2,y2, txt=None): elements = [] # x1, y1 = r1.get_cx(), r1.get_cy() # x2, y2 = r2.get_cx(), r2.get_cy(), l = line(x1, y1, x2, y2) elements.append(l) style = 'stroke-width:{0};stroke:{1}'.format(16, ALUM_6) l.set_style(style) if txt: x, y = middle(x1, y1, x2, y2) style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit # whole alphabet in this font is 167 px width per_char = 167./26 t = text(txt, -len(txt)/2*per_char, 4) t.set_style(style2.getStyle()) #import pdb; pdb.set_trace() group = rotate([t], slope_angle(x1, y1, x2, y2)) group = translate([group], x, y) elements.append(group) return elements
def rev_path(x1, y1, x2, y2, txt=None): elements = [] # x1, y1 = r1.get_cx(), r1.get_cy() # x2, y2 = r2.get_cx(), r2.get_cy(), l = line(x1, y1, x2, y2) elements.append(l) style = 'stroke-width:{0};stroke:{1}'.format(16, ALUM_6) l.set_style(style) if txt: x, y = middle(x1, y1, x2, y2) style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit # whole alphabet in this font is 167 px width per_char = 167. / 26 t = text(txt, -len(txt) / 2 * per_char, 4) t.set_style(style2.getStyle()) #import pdb; pdb.set_trace() group = rotate([t], slope_angle(x1, y1, x2, y2)) group = translate([group], x, y) elements.append(group) return elements
def drawSideFacePair(topCorners, bottomCorners, color): pointList = [] pointList2 = [] output = G() XYStyle1 = StyleBuilder() #XYStyle1.setStroke('black') #XYStyle1.setStrokeWidth(1.5) XYStyle1.setFilling(color) #XYStyle1.setFillOpacity(0.8) XYStyle2 = StyleBuilder() XYStyle2.setStroke(color) XYStyle2.setStrokeWidth(0.5) XYStyle2.setFilling(color) pointList.append(strPathStart(topCorners[2])) pointList.append(strPathPoint(topCorners[3])) pointList.append(strPathPoint(bottomCorners[3])) pointList.append(strPathPoint(bottomCorners[2])) svgCode1 = pGram(pointList) pointList2.append(strPathStart(topCorners[0])) pointList2.append(strPathPoint(topCorners[1])) pointList2.append(strPathPoint(bottomCorners[1])) pointList2.append(strPathPoint(bottomCorners[0])) svgCode2 = pGram(pointList2) rightFace = Path(svgCode1) rightFace.set_style(XYStyle1.getStyle()) leftFace = Path(svgCode2) leftFace.set_style(XYStyle2.getStyle()) output.addElement(leftFace) output.addElement(rightFace) return output
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 genHoneycomb(self): outComb = G() circleStyle = StyleBuilder() #circleStyle.setStrokeWidth(0.5) circleStyle.setStroke('orange') circleStyle.setFilling('#edd239') CORNER = self.hCSlice.getBottomRight() circleY = [] circleY.append(CORNER[1] + (ROW_SPACE - CIRCLE_RADIUS)) for g in range(0, self.row): circleX = CORNER[0] - CIRCLE_RADIUS if (g != 0 and g % 2 != 0): circleY.append(circleY[g-1] + 2*CIRCLE_RADIUS) elif (g!= 0 and g % 2 == 0): circleY.append(circleY[g-1] + 2*(ROW_SPACE - CIRCLE_RADIUS)) #initCircle = Circle(circleX, circleY[g], CIRCLE_RADIUS) #outComb.addElement(initCircle) for i in range(0, self.col): newShift = TransformBuilder() xShift = -i*CIRCLE_RADIUS*math.sqrt(3) yShift = 0 if i % 2 != 0 and g % 2 != 0: yShift = CIRCLE_RADIUS elif i % 2 != 0 and g % 2 == 0: yShift = -1*CIRCLE_RADIUS newShift.setTranslation(str(xShift) + ' ' + str(yShift)) a = Circle(circleX, circleY[g], CIRCLE_RADIUS) a.set_transform(newShift.getTransform()) outComb.addElement(a) outComb.set_style(circleStyle.getStyle()) return outComb
def draw(self): rectangleStyle = StyleBuilder() rectangleStyle.setStroke('black') rectangleStyle.setStrokeWidth(2) rectangleStyle.setFilling(self.color) self.view = Rect(self.gridCoord[0], self.gridCoord[1], self.dimA*SCALING_FACTOR, self.dimB*SCALING_FACTOR) self.view.set_style(rectangleStyle.getStyle()) return self.view
def words(txt, family='arial', weight='bold', color=ALUM_1): style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) t = text(txt, 0, 0) t.set_style(style2.getStyle()) return t
def words(txt, family='arial', weight='bold', color=ALUM_1): style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) t = text(txt, 0, 0) t.set_style(style2.getStyle()) return t
def makerow(self): frameStyle = StyleBuilder() frameStyle.setStrokeWidth(1.5) frameStyle.setStroke('black') frameStyle.setFilling('white') out = G() yCoord = 10 + (FRAMELEN + 20) * self.i for z in range(0, 4): newFrame = Rect(10 + (FRAMELEN + 20) * z, yCoord, FRAMELEN, FRAMELEN) newFrame.set_style(frameStyle.getStyle()) out.addElement(newFrame) self.rowCoords.append([10 + (FRAMELEN + 20) * z, yCoord]) return out
def num(txt, color): txt = str(txt) elems = [] r = rect(0, 0, 16, 16) s = StyleBuilder() s.setFilling(color) r.set_style(s.getStyle()) elems.append(r) if txt: style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit if len(txt) == 1: x = 5 elif len(txt) == 2: x = 1.5 t = text(txt, x, 12.5) t.set_style(style2.getStyle()) elems.append(t) return elems
def num(txt, color): txt = str(txt) elems = [] r = rect(0, 0, 16, 16) s = StyleBuilder() s.setFilling(color) r.set_style(s.getStyle()) elems.append(r) if txt: style2 = StyleBuilder() #style2.setFontFamily('envy code r') style2.setFontFamily('arial') style2.setFontWeight('bold') style2.setFilling(ALUM_1) # shift text left and up by a bit if len(txt) == 1: x = 5 elif len(txt) == 2: x = 1.5 t = text(txt, x, 12.5) t.set_style(style2.getStyle()) elems.append(t) return elems
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
def genHoneyRect(self): rectangleStyle = StyleBuilder() rectangleStyle.setFilling('blue') rectangleStyle.setStroke('black') # temp self.hCSlice.set_style(rectangleStyle.getStyle()) return(self.hCSlice)