Kaydet (Commit) 2ca7795a authored tarafından László Németh's avatar László Németh

LibreLogo: CLOSE closes, FILL fills points, too

Example: drawing square within a circle:

    PENUP
    REPEAT 4 [
        FORWARD 100
        POINT
        BACK 100
        RIGHT 360/4
    ] FILL
    CIRCLE 200

Change-Id: Ica3ce44306fc985717ff73e8a3dec5dddf69f19b
üst 1a2479c9
...@@ -103,6 +103,7 @@ class __Doc__: ...@@ -103,6 +103,7 @@ class __Doc__:
self.fontheight = 12 self.fontheight = 12
self.fontweight = 100 self.fontweight = 100
self.fontstyle = 0 self.fontstyle = 0
self.points = []
from math import pi, sin, cos, asin, sqrt, log10 from math import pi, sin, cos, asin, sqrt, log10
...@@ -930,6 +931,8 @@ def __go__(shapename, n, dot = False, preciseAngle = -1): ...@@ -930,6 +931,8 @@ def __go__(shapename, n, dot = False, preciseAngle = -1):
return return
if not _.pen and not dot: if not _.pen and not dot:
return return
if _.pen and not dot:
_.points = [] # new line drawing: forget the points
shape = __draw__("PolyLineShape") shape = __draw__("PolyLineShape")
shape.RotateAngle = 0 shape.RotateAngle = 0
shape.PolyPolygon = tuple([tuple([__Point__(0, 0)])]) shape.PolyPolygon = tuple([tuple([__Point__(0, 0)])])
...@@ -964,8 +967,21 @@ def __go__(shapename, n, dot = False, preciseAngle = -1): ...@@ -964,8 +967,21 @@ def __go__(shapename, n, dot = False, preciseAngle = -1):
def __fillit__(filled = True): def __fillit__(filled = True):
oldshape = __getshape__(__ACTUAL__) oldshape = __getshape__(__ACTUAL__)
if oldshape and oldshape.LineStartCenter: if (oldshape and oldshape.LineStartCenter) or _.points:
__removeshape__(__ACTUAL__) # FIXME close dotted polyline if oldshape:
__removeshape__(__ACTUAL__) # FIXME close dotted polyline
if _.points:
p = position()
h = heading()
for i in _.points:
position(i)
__pen__(1)
__checkhalt__()
_.points = []
__fillit__(filled)
__pen__(0)
position(p)
heading(h)
return return
if oldshape and "LineShape" in oldshape.ShapeType: if oldshape and "LineShape" in oldshape.ShapeType:
shape = __draw__("PolyPolygonShape", False) shape = __draw__("PolyPolygonShape", False)
...@@ -1016,6 +1032,7 @@ def point(): ...@@ -1016,6 +1032,7 @@ def point():
oldstyle, _.linestyle = _.linestyle, __LineStyle_DOTTED__ oldstyle, _.linestyle = _.linestyle, __LineStyle_DOTTED__
__go__(__TURTLE__, 0, True) __go__(__TURTLE__, 0, True)
_.pen, _.linestyle = oldpen, oldstyle _.pen, _.linestyle = oldpen, oldstyle
_.points.append(position())
def __boxshape__(shapetype, l): def __boxshape__(shapetype, l):
turtle = __getshape__(__TURTLE__) turtle = __getshape__(__TURTLE__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment