#main_script
import fmeobjects
import numpy as np
from fmeobjects import FMELine, FMEPoint, FMEPolygon
from math import sqrt, sin, cos, pi, degrees
width = 360
N = 10
d = width / N
l = d / 32
r = d/4.4
class FeatureProcessor(object):
def __init__(self):
pass
def geometry_group(self, tx, ty, radius, h, w):
# notice i switched w and h parameters of it
_center_point = FMEPoint()
for i in range(5):
newFeature= fmeobjects.FMEFeature()
x = tx + (d / 4 * cos(pi*2 / 5 * i - pi / 10))
y = ty + (d / 4 * sin(pi*2 / 5 * i - pi / 10))
_center_point.setXYZ(float(w/2+x), float(h/2+y), 0)
newFeature.setGeometry(_center_point)
newFeature.buffer(float(radius), 1.0)
self.pyoutput(newFeature)
newFeature= fmeobjects.FMEFeature()
newFeature.setGeometry(_center_point)
newFeature.buffer(float(radius), 1.0)
rotation = pi*2 / 5 * i + pi- pi / 10
# play with the arcs
# (centerPoint, rotation, primaryRadius, secondaryRadius, startAngle, sweepAngle)
_arc = fmeobjects.FMEArc(_center_point, 0.0, radius, radius, 0.0, 260.0)
_arc.rotate2D(_center_point, float(degrees(rotation)))
newFeature.setGeometry(_arc)
self.pyoutput(newFeature)
def pattern(self, size):
l = size / sqrt(4)
polygons = []
for i in range(N):
y = d * (i + 0.5)
for j in range(N):
x = d * (j + 0.5)
pos = (x,y)
poly = self.geometry_group(pos[0], pos[1], r, d, d)
def input(self, feature: fmeobjects.FMEFeature):
# svg_body = create_svg_no_deps(datastructure,'foo')
pass
def close(self):
points = self.pattern(d)