X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TestPatterns.pde;h=38ea2296200d31e7f13e370a7d1f3acc35a7df7d;hb=f5d9de39b45481476cfa2a34d30aa8c6578f7d9c;hp=52e8ea45f72a2929cf371b55ef38be3834b0df4e;hpb=45f43cc2debb7f90b01e7a5c7d355218ab9cdeed;p=SugarCubes.git diff --git a/TestPatterns.pde b/TestPatterns.pde index 52e8ea4..38ea229 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -74,6 +74,33 @@ class TestZPattern extends SCPattern { } } +/** + * This shows how to iterate over towers, enumerated in the model. + */ +class TestTowerPattern extends SCPattern { + private final SawLFO towerIndex = new SawLFO(0, model.towers.size(), 1000*model.towers.size()); + + public TestTowerPattern(GLucose glucose) { + super(glucose); + addModulator(towerIndex).trigger(); + } + + public void run(int deltaMs) { + int ti = 0; + for (Tower t : model.towers) { + for (Point p : t.points) { + colors[p.index] = color( + lx.getBaseHuef(), + 100, + max(0, 100 - 80*LXUtils.wrapdistf(ti, towerIndex.getValuef(), model.towers.size())) + ); + } + ++ti; + } + } + +} + /** * This is a demonstration of how to use the projection library. A projection * creates a mutation of the coordinates of all the points in the model, creating @@ -187,23 +214,13 @@ class MappingTool extends SCPattern { MappingTool(GLucose glucose, PandaMapping[] pandaMappings) { super(glucose); this.pandaMappings = pandaMappings; - int totalChannels = 0; - for (PandaMapping pm : pandaMappings) { - totalChannels += pm.channelList.length; - } - numChannels = totalChannels; + numChannels = pandaMappings.length * PandaMapping.CHANNELS_PER_BOARD; setChannel(); } private void setChannel() { - mappingChannelIndex = channelIndex; - for (PandaMapping pm : pandaMappings) { - if (mappingChannelIndex < pm.channelList.length) { - activeMapping = pm; - break; - } - mappingChannelIndex -= pm.channelList.length; - } + mappingChannelIndex = channelIndex % PandaMapping.CHANNELS_PER_BOARD; + activeMapping = pandaMappings[channelIndex / PandaMapping.CHANNELS_PER_BOARD]; } private int cubeInChannel(Cube c) {