Passed
Push — design ( fcd95c )
by Matt
02:23
created

PyDMXControl.design.parts._Pipe   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Pipe.__init__() 0 5 1
A Pipe.design_render() 0 10 1
1
"""
2
 *  PyDMXControl: A Python 3 module to control DMX using uDMX.
3
 *                Featuring fixture profiles, built-in effects and a web control panel.
4
 *  <https://github.com/MattIPv4/PyDMXControl/>
5
 *  Copyright (C) 2018 Matt Cowley (MattIPv4) ([email protected])
6
"""
7
8
import pygame
9
10
from ._Part import Part
11
from .._screen import Screen
12
13
14
class Pipe(Part):
15
16
    def __init__(self, size: int, x: int, y: int, rotation: int = 0):
17
        super().__init__()
18
        self.__rotation = rotation
19
        self.__length = size
20
        self.set_pos(x, y)
21
22
    def design_render(self, screen: Screen):
23
        # Create the surface
24
        surface = pygame.Surface((self.__length * screen.block_size, screen.block_size))
25
        surface.fill([80] * 3)
26
27
        # Rotate
28
        surface = pygame.transform.rotate(surface, self.__rotation)
29
30
        # Render
31
        screen.screen.blit(surface, (self._x * screen.block_size, self._y * screen.block_size))
32