VPATH=../../sources/vector
+SEED=seed
TURNIP=turnip1 turnip2 turnip3
MOULD_BODY=mouldA mouldB mouldC
MOULD=eyeballA eyeballB eyeballC
LIGHT=spotlight lamp laser
+LIGHT_MASK=light_mask_2_1 light_mask_2_2 light_mask_3_1 light_mask_3_2 light_mask_3_3
IMG16=$(MOULD_BODY)
-IMG32=$(MOULD_BODY) $(MOULD) $(LIGHT) seed
-IMG48=$(LIGHT) $(TURNIP)
+IMG32=$(MOULD_BODY) $(MOULD) $(LIGHT) $(SEED) $(LIGHT_MASK)
+IMG48=$(LIGHT) $(TURNIP) $(LIGHT_MASK)
IMG64=$(MOULD_BODY)
-CURSORS=seed $(LIGHT)
+CURSORS=$(SEED) $(LIGHT)
PNG16=$(patsubst %, 16/%.png, $(IMG16))
PNG32=$(patsubst %, 32/%.png, $(IMG32))
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="100mm"
+ height="100mm"
+ viewBox="0 0 354.33071 354.33071"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="light_mask_2_1.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.7"
+ inkscape:cx="299.65034"
+ inkscape:cy="154.13204"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1264"
+ inkscape:window-height="720"
+ inkscape:window-x="102"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4423"
+ units="mm"
+ spacingx="3.543307"
+ spacingy="3.543307" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-698.0315)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path4146"
+ sodipodi:type="arc"
+ sodipodi:cx="177.16536"
+ sodipodi:cy="875.19684"
+ sodipodi:rx="256.88977"
+ sodipodi:ry="256.88977"
+ sodipodi:start="4.712389"
+ sodipodi:end="1.5707963"
+ d="M 177.16536,618.30707 A 256.88977,256.88977 0 0 1 434.05513,875.19684 256.88977,256.88977 0 0 1 177.16537,1132.0866 l -1e-5,-256.88976 z" />
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="100mm"
+ height="100mm"
+ viewBox="0 0 354.33071 354.33071"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="light_mask_2_2.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.7"
+ inkscape:cx="299.65034"
+ inkscape:cy="154.13204"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1264"
+ inkscape:window-height="720"
+ inkscape:window-x="102"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4423"
+ units="mm"
+ spacingx="3.543307"
+ spacingy="3.543307" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-698.0315)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path4146"
+ sodipodi:type="arc"
+ sodipodi:cx="177.16536"
+ sodipodi:cy="875.19684"
+ sodipodi:rx="256.88977"
+ sodipodi:ry="256.88977"
+ sodipodi:start="1.5707963"
+ sodipodi:end="4.712389"
+ d="m 177.16537,1132.0866 a 256.88977,256.88977 0 0 1 -222.473076,-128.4449 256.88977,256.88977 0 0 1 -10e-7,-256.88975 256.88977,256.88977 0 0 1 222.473067,-128.44488 l 0,256.88977 z" />
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="100mm"
+ height="100mm"
+ viewBox="0 0 354.33071 354.33071"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="light_mask_3_1.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.7"
+ inkscape:cx="71.078911"
+ inkscape:cy="154.13204"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1264"
+ inkscape:window-height="720"
+ inkscape:window-x="102"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4423"
+ units="mm"
+ spacingx="3.543307"
+ spacingy="3.543307" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-698.0315)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path4146"
+ sodipodi:type="arc"
+ sodipodi:cx="177.16536"
+ sodipodi:cy="875.19684"
+ sodipodi:rx="256.88977"
+ sodipodi:ry="256.88977"
+ sodipodi:start="4.712389"
+ sodipodi:end="0.52359878"
+ d="m 177.16536,618.30707 a 256.88977,256.88977 0 0 1 222.47307,128.44489 256.88977,256.88977 0 0 1 0,256.88974 L 177.16536,875.19684 Z" />
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="100mm"
+ height="100mm"
+ viewBox="0 0 354.33071 354.33071"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="light_mask_3_2.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.7"
+ inkscape:cx="-157.49252"
+ inkscape:cy="154.13204"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1264"
+ inkscape:window-height="720"
+ inkscape:window-x="102"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4423"
+ units="mm"
+ spacingx="3.543307"
+ spacingy="3.543307" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-698.0315)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path4146"
+ sodipodi:type="arc"
+ sodipodi:cx="177.16536"
+ sodipodi:cy="875.19684"
+ sodipodi:rx="256.88977"
+ sodipodi:ry="256.88977"
+ sodipodi:start="0.52359878"
+ sodipodi:end="2.6179939"
+ d="M 399.63843,1003.6417 A 256.88977,256.88977 0 0 1 177.16536,1132.0866 256.88977,256.88977 0 0 1 -45.307711,1003.6417 L 177.16536,875.19684 Z" />
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="100mm"
+ height="100mm"
+ viewBox="0 0 354.33071 354.33071"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.91 r13725"
+ sodipodi:docname="light_mask_3_3.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.7"
+ inkscape:cx="71.078911"
+ inkscape:cy="154.13204"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1264"
+ inkscape:window-height="720"
+ inkscape:window-x="102"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:object-nodes="true"
+ inkscape:snap-smooth-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4423"
+ units="mm"
+ spacingx="3.543307"
+ spacingy="3.543307" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-698.0315)">
+ <path
+ style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="path4146"
+ sodipodi:type="arc"
+ sodipodi:cx="177.16536"
+ sodipodi:cy="875.19684"
+ sodipodi:rx="256.88977"
+ sodipodi:ry="256.88977"
+ sodipodi:start="2.6179939"
+ sodipodi:end="4.712389"
+ d="m -45.307711,1003.6417 a 256.88977,256.88977 0 0 1 6e-6,-256.88975 256.88977,256.88977 0 0 1 222.473065,-128.44488 l 0,256.88977 z" />
+ </g>
+</svg>
from .rays import RayPolyManager
from .utils import DetailedTimer
from .loader import loader
-from .transforms import Multiply
+from .transforms import Multiply, MultiplyImage
LIGHT_FILTER = pymunk.ShapeFilter(
mask=pymunk.ShapeFilter.ALL_MASKS ^ (
self.body, self.FITTING_RADIUS, self.ray_manager.position)
self.fitting.filter = FITTINGS_FILTER
self._fitting_image = None
+ self._colour_mult_image = None
@property
def position(self):
def fitting_image(self):
if self._fitting_image is None:
- fitting_colour = COLOURS[self.colour]
- self._fitting_image = loader.load_image(
+ fitting_colours = [COLOURS[c] for c in self.colour_cycle]
+ ncolour = len(fitting_colours)
+ if ncolour > 3:
+ print "Multicoloured light should not have more than 3 colours"
+ ncolour = 3
+
+ if ncolour == 1:
+ self._fitting_image = loader.load_image(
"48", self.FITTING_IMG,
- transform=Multiply(colour=fitting_colour))
+ transform=Multiply(colour=fitting_colours[0]))
+ else:
+ if self._colour_mult_image is None:
+ self._colour_mult_image = pygame.surface.Surface((48, 48))
+
+ for i in range(ncolour):
+ sector = loader.load_image(
+ "48", "light_mask_%d_%d.png" % (ncolour, i + 1),
+ transform=Multiply(colour=fitting_colours[i]))
+ self._colour_mult_image.blit(sector, (0,0), None, 0)
+
+ self._fitting_image = loader.load_image(
+ "48", self.FITTING_IMG,
+ transform=MultiplyImage(image=self._colour_mult_image))
+
return self._fitting_image
def invalidate_fitting_image(self):
FITTING_IMG = "lamp.png"
-class MultiColourLamp(BaseLight):
-
- FITTING_IMG = "lamp.png"
-
- def __init__(self, **kw):
- super(MultiColourLamp, self).__init__(**kw)
-
-
class PulsatingLamp(BaseLight):
FITTING_IMG = "lamp.png"
return surface
+class MultiplyImage(Transform):
+ """ Apply a colour by multiplying. """
+
+ ARGS = ["image"]
+
+ def apply(self, surface):
+ surface.blit(self.image, (0, 0), None, pgl.BLEND_RGBA_MULT)
+ return surface
+
+
class Alpha(Transform):
""" Make translucent. """