Hype

github.com / HYPE_Processing
by Joshua Davis and James Cruz
for Processing and ProcessingJS

HYPE_processing, is a collection of classes that performs heavy lifting tasks while using a minimal amount of code writing.
<< back

Your browser does not support the canvas tag.

ex15_NoCasting

HYPE, HEllipse, HRect, HPath

Source code
/* 
 * This testfile demonstrates the recently added
 * feature that lets you call H.add() and remove()
 * to assign variables without needing to cast them.
 *
 * Be noted that the problems presented in this test
 * file were only relevant in *Java Mode*, due to the
 * language's strict typing.
 *
 * --------------
 * Instead of:
 *
 *     HRect r = (HRect) H.add(new HRect());
 * 
 * You can now do this:
 * 
 *     HRect r = H.add(new HRect());
 * 
 * 
 *
 * Technical:
 * ----------
 * I simply made multiple add() and remove() methods
 * for each drawable class in class H.
 * 
 * Even though I have more than one of each of the
 * aforementioned methods, this wouldn't cause an
 * issue with JS Mode. All those functions would have
 * just merged into the original H.add() and H.remove()
 * functions, which would work just fine due to its
 * weak typing.
 */

void setup() {
	size(640,640);
	H.init(this).background(#202020);
	smooth();

	H.add( new HEllipse() )
		.size(100)
		.strokeWeight(6)
		.stroke(#000000, 100)
		.fill(#FFCC00)
		.anchorAt(H.CENTER)
		.loc(100, height/2)
	;

	H.add( new HRect() )
		.size(100)
		.strokeWeight(6)
		.stroke(#000000, 100)
		.fill(#FF9900)
		.anchorAt(H.CENTER)
		.loc(250, height/2)
	;

	H.add( new HPath() )
		.star(5, 0.5, 90)
		.size(110)
		.strokeWeight(6)
		.stroke(#000000, 100)
		.fill(#FF6600)
		.anchorAt(H.CENTER)
		.loc(400, height/2)
	;

	H.add( new HPath(POLYGON) )
		.vertex(490,270)
		.vertex(590,370)
		.vertex(490,370)
		.vertex(590,270)
		.strokeWeight(6)
		.stroke(#000000, 100)
		.fill(#FF3300)
	;

	/*
	* Here's the list of classes that you no longer need to
	* cast with H.add() and H.remove() as of build_21030531.0:
	* 
	* - HCanvas
	* - HEllipse
	* - HGroup
	* - HImage
	* - HPath
	* - HRect
	* - HShape
	* - HText
	*
	* If you created your own HDrawable class, then you'll still
	* need to do the old casting thing.
	*/

	H.drawStage();
	noLoop();
}

void draw() {}