Skip to content

Commit

Permalink
Released Version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Grigorian committed Jul 24, 2018
1 parent c17cfae commit 033ebca
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
> Pixel graphics in terminal implemented with unicode braille characters
![MIT License](https://img.shields.io/badge/License-MIT-lightgrey.svg?style=for-the-badge)
![Version 1.0.0](https://img.shields.io/badge/Version-1.0.0-lightgrey.svg?style=for-the-badge)
![Version 1.0.2](https://img.shields.io/badge/Version-1.0.2-lightgrey.svg?style=for-the-badge)
![Travis CI](https://img.shields.io/travis/null93/drawille.svg?style=for-the-badge&colorB=9f9f9f)

## About
Expand Down
Binary file removed dist/drawille-1.0.0.jar
Binary file not shown.
Binary file added dist/drawille-1.0.2.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>io.raffi</groupId>
<artifactId>drawille</artifactId>
<packaging>jar</packaging>
<version>1.0.1</version>
<version>1.0.2</version>
<name>drawille</name>
<url>http://maven.apache.org</url>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/raffi/drawille/BrailleMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This class stores a 4 by 2 pixel matrix that is eventually translated into a braille character.
* This method abstracts away all the calculations that is needed to transform a matrix into a
* braille character. This class is meant to be used as a sub-matrix.
* @version 1.0.1
* @version 1.0.2
* @package io.raffi.drawille
* @author Rafael Grigorian <me@raffi.io>
* @copyright 2018 Rafael Grigorian — All Rights Reserved
Expand Down
36 changes: 31 additions & 5 deletions src/main/java/io/raffi/drawille/Canvas.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.raffi.drawille;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;

/**
* This class is used to hold all the BrailleMap objects and uses them as sub-matrices. It is an
* abstraction of a pixel screen. Methods to interact with those pixels can be found in this class.
* @version 1.0.1
* @version 1.0.2
* @package io.raffi.drawille
* @author Rafael Grigorian <me@raffi.io>
* @copyright 2018 Rafael Grigorian — All Rights Reserved
Expand Down Expand Up @@ -145,15 +147,39 @@ public void clear () {
/**
* This method traverses through all the BrailleMap objects and renders out the sub-matrices by
* asking for the object's string value with the getString method. It then prints them all out
* to the screen.
* to the screen by using the overloaded cooresponding render method.
* @return void
*/
public void render () {
ByteArrayOutputStream stream = new ByteArrayOutputStream ();
try {
this.render ( stream );
}
catch ( IOException e ) {
System.out.print ( e );
}
System.out.print ( stream.toString () );
}

/**
* This method traverses through all the BrailleMap objects and renders out the sub-matrices by
* asking for the object's string value with the getString method. It then writes said output to
* the specified ByteArrayOutputStream. This stream is then returned back to caller for method
* chaining.
* @param ByteArrayOutputStream stream Stream to write to
* @return ByteArrayOutputStream Same stream that was passed in
* @throws IOException ByteArrayOutputStream throws exception
*/
public ByteArrayOutputStream render ( ByteArrayOutputStream stream ) throws IOException {
for ( int i = 0; i < this.width * this.height; i++ ) {
System.out.print ( this.screen [ i ] );
String brailleMap = this.screen [ i ].toString ();
byte [] buffer = brailleMap.getBytes ();
stream.write ( buffer );
if ( i % this.width == this.width - 1 ) {
System.out.println ("");
stream.write ( "\n".toString ().getBytes () );
}
}
return stream;
}

}
}
2 changes: 1 addition & 1 deletion src/main/java/io/raffi/drawille/DrawilleException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This class inherits from the RuntimeException class. It is meant to be thrown whenever an out of
* range value is passed to the Canvas and BrailleMap class. The message is statically defined in
* this class and the caller only has to pass in the out of bounds (x,y) value pairs.
* @version 1.0.1
* @version 1.0.2
* @package io.raffi.drawille
* @author Rafael Grigorian <me@raffi.io>
* @copyright 2018 Rafael Grigorian — All Rights Reserved
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/raffi/drawille/Turtle.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This class inherits from the Canvas class and it tries to implement turtle graphics. The methods
* in this class can be abstracted with an idea of a pen and paper. One can move the pen in three
* axis and based on the z axis, when the pen moves it either draws on the paper or not.
* @version 1.0.1
* @version 1.0.2
* @package io.raffi.drawille
* @author Rafael Grigorian <me@raffi.io>
* @copyright 2018 Rafael Grigorian — All Rights Reserved
Expand Down
17 changes: 15 additions & 2 deletions src/test/java/io/raffi/drawille/CanvasTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.raffi.drawille;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
Expand Down Expand Up @@ -126,4 +125,18 @@ public void testClearWorks () {
assertFalse ( canvas.get ( 1, 2 ) );
}

}
public void testRenderOverload () {
try {
ByteArrayOutputStream output = new ByteArrayOutputStream ();
Canvas canvas = new Canvas ( 1, 2 );
canvas.set ( 1, 1 );
canvas.set ( 1, 2 );
String result = canvas.render ( output ).toString ().replace ( "\n", "" );
assertTrue ( result.equals ("\u2830\u2800") );
}
catch ( Exception e ) {
assertTrue ( false );
}
}

}

0 comments on commit 033ebca

Please sign in to comment.