Exemple #1
0
    def __init__(self, parameters):
        super().__init__(parameters)
        self.SUPPORTED_TYPES = {'man', 'woman', 'cat'}
        self._set_default_type_if_needed('human')
        chosen_type = self._get_chosen_type()

        face_params = self.parameters
        face_params[EP.ASPECT_RATIO] = 'fit'

        if chosen_type is None:
            print('{} head type not implemented!'.format(
                self.parameters[EP.TYPE]))
        elif chosen_type == 'man':
            self.parts.append(
                Part(entity=Face(face_params),
                     relative_position=RelativePosition(top=0.05)))
            self.parts.append(
                Part(entity=Hair(self.parameters),
                     relative_position=RelativePosition(top=0.0,
                                                        bottom=0.35,
                                                        left=0.1,
                                                        right=0.9)))
        elif chosen_type == 'woman':
            self.parts.append(
                Part(entity=Face(face_params),
                     relative_position=RelativePosition(top=0.05, bottom=0.9)))
            self.parts.append(
                Part(entity=Hair(self.parameters),
                     relative_position=RelativePosition()))
        elif chosen_type == 'cat':
            self.parts.append(Part(entity=Face(face_params)))
Exemple #2
0
    def __init__(self, parameters):
        super().__init__(parameters)

        self.parts.append(
            Part(entity=Oval(parameters),
                 relative_position=RelativePosition(left=0,
                                                    top=0,
                                                    right=1,
                                                    bottom=1)))
Exemple #3
0
    def __init__(self, parameters):
        super().__init__(parameters)
        self.SUPPORTED_TYPES = {'human'}
        self._set_default_type_if_needed('human')
        chosen_type = self._get_chosen_type()

        if chosen_type is None:
            print('arms of {} not implemented!'.format(self.parameters[EP.TYPE]))
        elif  chosen_type == 'human':
            self.parts.append(Part(entity=Oval(self.parameters), relative_position=RelativePosition()))
Exemple #4
0
    def __init__(self, parameters):
        super().__init__(parameters)
        self.SUPPORTED_TYPES = {'human'}
        self._set_default_type_if_needed('human')
        chosen_type = self._get_chosen_type()

        if chosen_type == 'human':
            self.parts.append(
                Part(entity=Oval({EP.ASPECT_RATIO: Eye.ASPECT_RATIO['human']}),
                     relative_position=RelativePosition(left=0,
                                                        top=0,
                                                        right=1,
                                                        bottom=1)))
            self.parts.append(
                Part(entity=Oval({EP.ASPECT_RATIO: 1.0}),
                     relative_position=RelativePosition(top=0,
                                                        bottom=1,
                                                        left=0.25,
                                                        right=0.75)))
Exemple #5
0
    def __init__(self, parameters):
        parameters[EP.TYPE] = 'woman'
        super().__init__(parameters)
        self._change_default_aspect_ratio_to_value(0.7)

        self.parts.append(
            Part(Head(self.parameters),
                 relative_position=RelativePosition(bottom=1 / 7.5,
                                                    left=0.38,
                                                    right=0.62)))
        self.parts.append(
            Part(Torso(self.parameters),
                 relative_position=RelativePosition(left=0.2,
                                                    right=0.8,
                                                    top=1 / 7.5,
                                                    bottom=4 / 7.5)))
        self.add_part(Leg, left=0.38, right=0.43, top=4 / 7.5)
        self.add_part(Leg, left=0.58, right=0.63, top=4 / 7.5)
        self.add_part(Arm, left=0.4, right=0.41, top=1 / 7.5, bottom=4 / 7.5)
        self.add_part(Arm, left=0.57, right=0.6, top=1 / 7.5, bottom=4 / 7.5)
Exemple #6
0
 def add_part(self,
              part_type,
              top=0.0,
              bottom=1.0,
              left=0.0,
              right=1.0,
              aspect_ratio='default'):
     parameters = deepcopy(self.parameters)
     parameters[EP.ASPECT_RATIO] = aspect_ratio
     self.parts.append(
         Part(entity=part_type(parameters=parameters),
              relative_position=RelativePosition(left=left,
                                                 right=right,
                                                 top=top,
                                                 bottom=bottom)))
Exemple #7
0
    def __init__(self, params):
        super().__init__(params)
        self.SUPPORTED_TYPES = {'human'}
        self._set_default_type_if_needed('human')
        chosen_type = self._get_chosen_type()

        if chosen_type == 'human':
            self.parts.append(
                Part(
                    Triangle({
                        EP.TYPE: 'human_nose',
                        EP.ASPECT_RATIO: self.parameters[EP.ASPECT_RATIO]
                    }), RelativePosition()))
        else:
            'TODO'
Exemple #8
0
    def __init__(self, parameters):
        super().__init__(parameters)
        self.SUPPORTED_TYPES = {'man', 'woman'}
        self._set_default_type_if_needed('human')
        chosen_type = self._get_chosen_type()

        if chosen_type is None:
            print('{} hair type not implemented!'.format(
                self.parameters[EP.TYPE]))
        elif chosen_type == 'man':
            self.parts.append(
                Part(entity=Oval({
                    EP.LINE_THICKNESS: -1,
                    EP.COLOR: self.parameters[EP.COLOR]
                }),
                     relative_position=RelativePosition(left=0.0,
                                                        right=1.0,
                                                        top=0.0,
                                                        bottom=0.8)))
            self.parts.append(
                Part(entity=Oval({
                    EP.LINE_THICKNESS: -1,
                    EP.COLOR: self.parameters[EP.COLOR]
                }),
                     relative_position=RelativePosition(left=0.0,
                                                        right=0.1,
                                                        top=0.0,
                                                        bottom=1.0)))
            self.parts.append(
                Part(entity=Oval({
                    EP.LINE_THICKNESS: -1,
                    EP.COLOR: self.parameters[EP.COLOR]
                }),
                     relative_position=RelativePosition(left=0.9,
                                                        right=1.0,
                                                        top=0.0,
                                                        bottom=1.0)))
        elif chosen_type == 'woman':
            self.parts.append(
                Part(entity=Oval({
                    EP.LINE_THICKNESS: -1,
                    EP.COLOR: self.parameters[EP.COLOR]
                }),
                     relative_position=RelativePosition(left=0.0,
                                                        right=1.0,
                                                        top=0.0,
                                                        bottom=0.2)))
            self.parts.append(
                Part(entity=Oval({
                    EP.LINE_THICKNESS: -1,
                    EP.COLOR: self.parameters[EP.COLOR]
                }),
                     relative_position=RelativePosition(left=0.0,
                                                        right=0.1,
                                                        top=0.0,
                                                        bottom=1.0)))
            self.parts.append(
                Part(entity=Oval({
                    EP.LINE_THICKNESS: -1,
                    EP.COLOR: self.parameters[EP.COLOR]
                }),
                     relative_position=RelativePosition(left=0.9,
                                                        right=1.0,
                                                        top=0.0,
                                                        bottom=1.0)))
Exemple #9
0
 def __init__(self, entity, relative_position=RelativePosition()):
     self.entity = entity
     self.relative_position = relative_position
Exemple #10
0
    def __init__(self, parameters):
        super().__init__(parameters)
        self.SUPPORTED_TYPES = {'human', 'cat'}
        self._set_default_type_if_needed('human')
        chosen_type = self._get_chosen_type()
        self._change_default_aspect_ratio_to_value(
            Face.ASPECT_RATIO[chosen_type])

        if chosen_type is None:
            print('{} face not implemented'.format(self.parameters[EP.TYPE]))
        elif chosen_type in ['human',
                             'cat']:  # TODO move 'cat' into separate branch
            self.parameters[EP.TYPE] = 'human'
            brow_line = (math.sqrt(2)) / (2 + math.sqrt(2))
            nose_line = (1 + math.sqrt(2)) / (2 + math.sqrt(2))
            eyes_bottom_line = brow_line + 0.2 / Eye.ASPECT_RATIO[
                self.parameters[EP.TYPE]]
            mouth_height = 0.12
            mouth_center_height = (1.5 + math.sqrt(2)) / (2 + math.sqrt(2))
            self.parts.append(
                Part(entity=Oval({EP.ASPECT_RATIO: 'fit'}),
                     relative_position=RelativePosition(left=0.1,
                                                        top=0,
                                                        right=0.9,
                                                        bottom=1)))
            self.parts.append(
                Part(entity=Eye({
                    EP.SHAPE: Eye.STANDARD_SHAPE,
                    EP.TYPE: self.parameters[EP.TYPE]
                }),
                     relative_position=RelativePosition(
                         left=0.2,
                         top=brow_line,
                         right=0.4,
                         bottom=eyes_bottom_line)))
            self.parts.append(
                Part(entity=Eye({
                    EP.SHAPE: Eye.STANDARD_SHAPE,
                    EP.TYPE: self.parameters[EP.TYPE]
                }),
                     relative_position=RelativePosition(
                         left=0.6,
                         top=brow_line,
                         right=0.8,
                         bottom=eyes_bottom_line)))
            self.parts.append(
                Part(entity=Nose({EP.TYPE: self.parameters[EP.TYPE]}),
                     relative_position=RelativePosition(left=0.4,
                                                        right=0.6,
                                                        top=eyes_bottom_line,
                                                        bottom=nose_line)))
            self.parts.append(
                Part(entity=Mouth({EP.TYPE: self.parameters[EP.TYPE]}),
                     relative_position=RelativePosition(
                         left=0.32,
                         right=0.68,
                         top=mouth_center_height - mouth_height / 2,
                         bottom=mouth_center_height + mouth_height / 2)))
            self.parts.append(
                Part(entity=Ear({EP.TYPE: self.parameters[EP.TYPE]}),
                     relative_position=RelativePosition(left=0,
                                                        right=0.1,
                                                        top=brow_line,
                                                        bottom=nose_line)))
            self.parts.append(
                Part(entity=Ear({EP.TYPE: self.parameters[EP.TYPE]}),
                     relative_position=RelativePosition(left=0.9,
                                                        right=1.0,
                                                        top=brow_line,
                                                        bottom=nose_line)))