def baix(i, j, bd, pibg, xml, xml_id, coo_of): """ make the rectangle and text of a baix """ xml_id = xml_id + 1 [x,y] = bd['baix_pos'] xml += xml_position.substitute(_x=x, \ _y=y, \ _rx = bd['baix_rect_dim']['x'], \ _ry = bd['baix_rect_dim']['y'], \ _rw = bd['baix_rect_dim']['w'], \ _rh = bd['baix_rect_dim']['h'], \ _angle = bd['baix_rect_dim']['angle'], \ _xml_id=xml_id,\ #_xml_text = str([i,j]), \ _xml_text=xml_id, \ _class='baix', \ _name=xml_id, \ _index_props=[i,j]) pibg[i,j] = dict([('xml_id', xml_id), \ ('role', 'baix'), \ #('xml_text', 'baix'), \ ('xml_text', xml_id), \ ('x', x), \ ('y', y), \ ('angle', bd['baix_rect_dim']['angle'])]) coo_of[xml_id] = [x,y] return [xml, xml_id, pibg, coo_of]
def pc(i, j, index, pcd, pipcg, xml, xml_id, coo_of): """ make one portacrossa """ xml_id = xml_id + 1 [x,y] = pcd[index + '_pos'] dims = pcd[index + '_dim'] alpha = dims['angle'] xml += xml_position.substitute(_x=x, \ _y=y, \ _rx = dims['x'], \ _ry = dims['y'], \ _rw = dims['w'], \ _rh = dims['h'], \ _angle = alpha, \ _xml_id=xml_id,\ #_xml_text = str([i,j]), \ _xml_text=xml_id, \ _class='portacrossa', \ _name=xml_id, \ _index_props=[i,j]) pipcg[i,j] = dict([('xml_id', xml_id), \ ('role', 'portacrossa'), \ #('xml_text', 'portacrossa'), \ ('xml_text', xml_id), \ ('x', x), \ ('y', y), \ ('angle', alpha)]) coo_of[xml_id] = [x,y] return [xml, xml_id, pipcg, coo_of]
def segon(i, x, y, angle, sd, pis, xml, xml_id, coo_of): """ make the rectangle and text of a segon """ xml_id = xml_id + 1 xml += xml_position.substitute(_x=x, \ _y=y, _rx = sd['segon_rect_dim']['x'], \ _ry = sd['segon_rect_dim']['y'], \ _rw = sd['segon_rect_dim']['w'], \ _rh = sd['segon_rect_dim']['h'], \ _angle = angle, \ _xml_id=xml_id,\ #_xml_text = str([i,j]), \ _xml_text=xml_id, \ _class='segon', \ _name=xml_id, \ _index_props=i) pis[i] = dict([('xml_id', xml_id), \ ('role', 'segon'), \ #('xml_text', 'agulla'), \ ('xml_text', xml_id), \ ('x', x), \ ('y', y), \ ('angle', angle)]) coo_of[xml_id] = [x,y] return [xml, xml_id, pis, coo_of]
def lateral(i, j, bd, pibg, xml, xml_id, coo_of): """ make the rectangle and text of a lateral """ xml_id = xml_id + 1 [x,y] = bd['lateral_pos'] alpha = bd['lateral_rect_dim']['angle'] if j[-1] == '2': y = -y alpha = -alpha xml += xml_position.substitute(_x=x, \ _y=y, \ _rx = bd['lateral_rect_dim']['x'], \ _ry = bd['lateral_rect_dim']['y'], \ _rw = bd['lateral_rect_dim']['w'], \ _rh = bd['lateral_rect_dim']['h'], \ _angle = alpha, \ _xml_id=xml_id,\ #_xml_text = str([i,j]), \ _xml_text=xml_id, \ _class='lateral', \ _name=xml_id, \ _index_props=[i,j]) pibg[i,j] = dict([('xml_id', xml_id), \ ('role', 'lateral'), \ #('xml_text', 'crossa'), \ ('xml_text', xml_id), \ ('x', x), \ ('y', y), \ ('angle', alpha)]) coo_of[xml_id] = [x,y] return [xml, xml_id, pibg, coo_of]
def ring(period, i, r, pinya_rect_dim, xml_id, position_in_ring, coo_of): """ create the xml elements in the outer rings of pinya. period = k if the ring has 2pi/k symmetry i: the index of the ring; also, how many people are between each of the rays at 2pi j / k r: the radius of the ring pinya_rect_dim: The dimensions of the box to place, of the form {w:20 h:30} init_xml_id: The first free id for an xml element returns: xml: the string with the xml representation xml_id: the next free id number position_in_ring: The dictionary telling the id of an element at the position (j, s) coo_of: the coordinates of an element with a certain id """ xml = '' dyn_props = '' for j in range(2*period): for m in range(i+1): a = 2 * pi * ( j + m / float(i + 1) ) / float(2*period) xml_id = xml_id + 1 if m == 0: if j%2 == 0: c = 'ma' # Ma role = 'ma' else: c = 'vent' # Vent role = 'vent' else: c = 'pinya' # Quesito role = 'pinya' x=round(r*cos(a), 2) y=round(r*sin(a), 2) angle = round(a*180/pi, 2) xml += xml_position.substitute(_x=x, _y=y, \ _rx=-0.5*pinya_rect_dim['w'], _ry=-0.5*pinya_rect_dim['h'], \ _rw=pinya_rect_dim['w'], _rh=pinya_rect_dim['h'], \ _angle=angle, \ _xml_id=xml_id,\ #_xml_text = str([i,j,m]), \ _xml_text=xml_id, \ _class=c, \ _name=xml_id, \ _index_props=[i,j,m]) position_in_ring[i,j,m] = dict([('xml_id', xml_id), \ ('role', role), \ #('xml_text', role), \ ('xml_text', xml_id), \ ('x', x), \ ('y', y), \ ('angle', angle)]) coo_of[xml_id] = [x,y] return [xml, xml_id, position_in_ring, coo_of]