Last active
December 18, 2015 21:38
-
-
Save mactkg/5848347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PFont font; | |
| void setup() { | |
| size(500, 500); | |
| font = createFont("HGSHeiseiKakugothictai"); | |
| textFont(font); | |
| textSize(50); | |
| } | |
| int kuji = 0; | |
| void draw() { | |
| background(255, 255, 255); | |
| showIntValue(0, "kuji", kuji); | |
| fill(0, 0, 0); | |
| if(kuji==0) { | |
| println("kita----"); | |
| text("凶", 100, 100); | |
| } | |
| else if(kuji==1) { | |
| text("小吉", 100, 100); | |
| } | |
| else if(kuji==2) { | |
| text("中吉", 100, 100); | |
| } | |
| else if(kuji==3) { | |
| text("大吉", 100, 100); | |
| } | |
| kuji = kuji + 1; | |
| if(kuji>3) kuji = 0; | |
| } | |
| // -- 8< - 8< -- ここから下をコピペして使って --- 8< - 8< -------- | |
| // 変数の情報を表示するための関数ですので無視してくれて結構です | |
| // 0番から始めて,1,2,3,4と順に下に並んでいきます | |
| // [使い方] | |
| // 整数を表示する場合 showIntValue( 0, "x", x ); | |
| // 実数を表示する場合 showIntValue( 0, "面積", r*r*3.14 ); | |
| // booleanを表示する場合 showBoolValue( 0, "flag", flag ); | |
| // 文字列を表示する場合 showIntValue( 0, "名前", nickname ); | |
| void showIntValue( int num, String name, int value ) { | |
| showValue( num, name, ""+value ); | |
| } | |
| void showFloatValue( int num, String name, float value ) { | |
| showValue( num, name, ""+value ); | |
| } | |
| void showBoolValue( int num, String name, boolean value ) { | |
| showValue( num, name, ""+value ); | |
| } | |
| void showValue( int num, String name, String value ) { | |
| int margin = 5; | |
| int unitWidth = 100; | |
| int unitHeight = 30; | |
| pushStyle(); | |
| textSize( 15 ); | |
| stroke( 0 ); | |
| strokeWeight( 1 ); | |
| fill( 255, 100 ); | |
| rect( width-unitWidth*2, num*unitHeight, unitWidth, unitHeight ); | |
| rect( width- unitWidth, num*unitHeight, unitWidth, unitHeight ); | |
| fill( 0 ); | |
| text( name, width-unitWidth*2+margin, (num+1)*unitHeight-margin ); | |
| text( ""+value, width-unitWidth+margin, (num+1)*unitHeight-margin ); | |
| popStyle(); | |
| } | |
| // -- 8< - 8< -- ここまでコピペして使って --- 8< - 8< ------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment