Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void flipVerticalRectangle(int x, int y, int width, int height)
- {
- for (int sourceY = y, i = 1; sourceY >= (y - (height-1)/2); sourceY--, i+=2)
- {
- if (y > 0 && y <= this.getHeight() + height)
- {
- for (int sourceX = x; sourceX <= (x + (width-1)); sourceX++)
- {
- if (x + width > 0 && x <= this.getWidth())
- {
- Pixel sourcePix = this.getPixel(sourceX, sourceY);
- Pixel targetPix = this.getPixel(sourceX, sourceY - (height-i));
- Color tempcolor = targetPix.getColor();
- targetPix.setColor(sourcePix.getColor());
- sourcePix.setColor(tempcolor);
- }
- }
- }
- }
- }
- /**
- * TODO: Add header comment and complete the method
- **/
- public void flipHorizontalRectangle(int x, int y, int width, int height)
- {
- // No change if square is completely outside picture
- if (!(x + width < 0 || y < 0 || x >= this.getWidth() || y >= this.getHeight() + height))
- {
- for (int sourceY = y; sourceY >= (y - (height-1)); sourceY--)
- {
- for (int sourceX = x, i = 1; sourceX <= (x + (width-1)/2); sourceX++, i+=2)
- {
- Pixel sourcePix = this.getPixel(sourceX, sourceY);
- Pixel targetPix = this.getPixel(width + (sourceX-i), sourceY);
- Color tempcolor = targetPix.getColor();
- targetPix.setColor(sourcePix.getColor());
- sourcePix.setColor(tempcolor);
- }
- }
- }
- }
- public void concatenateSound(Sound firstSound, Sound secondSound)
- {
- int endOfOriginal = this.getLength();
- int endOfFirstSound = firstSound.getLength();
- int endOfSecondSound = secondSound.getLength();
- for (int firstSoundi = 0; firstSoundi < endOfFirstSound; firstSoundi++)
- {
- this.setSampleValueAt(firstSoundi, firstSound.getSampleValueAt(firstSoundi));
- }
- for (int secondSoundi = endOfFirstSound, secondSoundj = 0; secondSoundj < endOfSecondSound; secondSoundi++, secondSoundj++)
- {
- this.setSampleValueAt(secondSoundi, secondSound.getSampleValueAt(secondSoundj));
- }
- for (int endSound = endOfSecondSound; endSound < endOfOriginal; endSound++)
- {
- this.setSampleValueAt(endSound, 0);
- }
- }
- public void concatenateSound(Sound firstSound, Sound secondSound, int switchPoint)
- {
- int endOfOriginal = this.getLength();
- int endOfFirstSound = firstSound.getLength();
- int endOfSecondSound = secondSound.getLength();
- for (int index = 0; index < endOfOriginal; index++)
- {
- if (endOfFirstSound < switchPoint) {
- for (int shortFirstSound = 0; shortFirstSound < endOfFirstSound; shortFirstSound++)
- {
- this.setSampleValueAt(shortFirstSound, firstSound.getSampleValueAt(shortFirstSound));
- }
- for (int secondSoundA = endOfFirstSound, secondSoundLength = 0; secondSoundA < endOfOriginal && secondSoundLength < endOfSecondSound; secondSoundA++, secondSoundLength++)
- {
- this.setSampleValueAt(secondSoundA, secondSound.getSampleValueAt(secondSoundLength));
- }
- }
- else if (switchPoint < endOfFirstSound) {
- for (int longFirstSound = 0; longFirstSound < switchPoint; longFirstSound++)
- {
- this.setSampleValueAt(longFirstSound, firstSound.getSampleValueAt(longFirstSound));
- }
- for (int secondSoundB = switchPoint, secondSoundLength = 0; secondSoundB < (endOfOriginal - 1) && secondSoundLength < endOfSecondSound; secondSoundB++, secondSoundLength++)
- {
- this.setSampleValueAt(secondSoundB, secondSound.getSampleValueAt(secondSoundLength));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment