-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed format decorators interface:
1. Removed the 'Decorator' sufix from class names: FillTypeDecorator -> FillType PenDecorator -> Pen 2. Arguments to formatters are now parameter values, not HPGL commands: FillTypeDecorator(FT(x)) -> FillType(x) Interface stays the same: ft = FillType(x) ft(shape) _______________________ < More cleanup pending. > ----------------------- \ \ __ UooU\.'@@@@@@`. \__/(@@@@@@@@@@) (@@@@@@@@) `YY~~~~YY' || ||
- Loading branch information
1 parent
6f1b1a9
commit ffb8dbe
Showing
8 changed files
with
48 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .pen import PenDecorator | ||
from .linetype import LineTypeDecorator | ||
from .filltype import FillTypeDecorator | ||
from .pen import Pen | ||
from .linetype import LineType | ||
from .filltype import FillType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
from chiplotle.hpgl.commands import FT | ||
from chiplotle.core.interfaces.formatdecorator import FormatDecorator | ||
|
||
class FillTypeDecorator(FormatDecorator): | ||
|
||
class FillType(FormatDecorator): | ||
|
||
def __init__(self, filltype): | ||
__doc__ = FT.__doc__ | ||
|
||
def __init__(self, filltype=None, space=None, angle=None): | ||
FormatDecorator.__init__(self) | ||
if not isinstance(filltype, FT): | ||
raise TypeError | ||
self.filltype = filltype | ||
self.space = space | ||
self.angle = angle | ||
|
||
|
||
@property | ||
def _subcommands(self): | ||
return [self.filltype] | ||
return [FT(self.filltype, self.space, self.angle)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,43 @@ | ||
from chiplotle.hpgl.pen import Pen | ||
from chiplotle.hpgl.pen import Pen as HPGLPen | ||
from chiplotle.core.interfaces.formatdecorator import FormatDecorator | ||
|
||
class PenDecorator(FormatDecorator): | ||
'''The PenDecorator wraps HPGL Pen properties around a given Shape. | ||
class Pen(FormatDecorator): | ||
'''The Pen wraps HPGL Pen properties around a given Shape. | ||
- `pen` is the pen number to use. | ||
- `sticky` boolean; set to False to set plotter back to default values | ||
at the end of the decorated shape. Set to True to skip reset. | ||
''' | ||
|
||
def __init__(self, pen): | ||
if not isinstance(pen, Pen): | ||
raise TypeError | ||
def __init__(self, | ||
number, | ||
velocity = None, | ||
force = None, | ||
acceleration= None, | ||
thickness = None): | ||
FormatDecorator.__init__(self) | ||
self.pen = pen | ||
self.number = number | ||
self.velocity = velocity | ||
self.force = force | ||
self.acceleration = acceleration | ||
self.thickness = thickness | ||
|
||
@property | ||
def _subcommands(self): | ||
return self.pen._subcommands | ||
#return [self.pen] | ||
p = HPGLPen(self.number, | ||
self.velocity, | ||
self.force, | ||
self.acceleration, | ||
self.thickness) | ||
return [p] | ||
|
||
|
||
|
||
## DEMO | ||
if __name__ == '__main__': | ||
from chiplotle.geometry.shapes.rectangle import rectangle | ||
|
||
p = Pen(2, 3, 4, 5, 0.1) | ||
pd = PenDecorator(p) | ||
pd = Pen(2, 3, 4, 5, 0.1) | ||
r = rectangle(100, 20) | ||
pd(r) | ||
print r.format |