BasicsTutorial/Shapes

Last-modified: 2008-02-21 (木) 15:07:20

Shapes

形状

Letters not exciting enough for you eh?
十分にあなたのために刺激的でない文字だけ、えっ?
Here is an example of all the commands that draw shapes.
形を描く全ての命令の例は、ここにある。

Dot 50,50
Line 100,100,600,100
Box 200,250,250,300
Circle 500,400,40
Ellipse 200,400,30,60
Wait key

Now how they all work.
現在、なんて、それ全員は働くだろう。
The dot command has 2 values, the x and y coordinates (the same as SET CURSOR, the x coordinate is along, the y coordinate is down, I will be using x and y from now on).
dot命令は、2つの値、xとy座標を持つ。(SET CURSOR、座標があるx、座標があるyと同じように、私は今後xとyを使っている)
The line has the x and y coordinates on the two ends of the line (x1,y1,x2,y2).
LINEはxとyを持っている、 line(x1,y1, x2,y2)の2つの端の座標です。
The box has the coordinates of the opposite corners, the circle has the x and y coordinates and the radius (distance from the centre of the circle to any point on the circumference (outside)) of the circle (x,y,radius), and the ellipse has the coordinates and the x and y radius.
BOXは反対側の角の座標を持つ、円はxとy座標と円(x,y,radius)の半径(円の中心から円周(外側の)のどんな点まででもの距離)を持つ、そして、楕円はxy座標と半径を持つ。

Using the RGB() command you can specify the colour of the shapes, with DOT and BOX you can also add an additional value for the colour.
RGB()命令を使う、あなたが形の色を指定することができる、 DOT と BOXで、あなたは色のために更なる値を加えることもできる。

Dot 50,50,rgb(0,255,100)
Wait key

With the BOX command you can do the same, only you specify the colour of all four corners.
あなたが同じようにすることができるというBOX命令で、あなただけは全4つの角の色を指定する。
The colours then blend into each other and you get a pretty effect.
色はそれから互いに融合する、そして、あなたはかわいい影響を得る。

Box 0,0,200,200,rgb(255,0,0),rgb(0,255,0),rgb(0,0,255),rgb(255,255,0)
Wait key

Again, use CLS to clear the screen of all text and shapes.
また、画面の全てのテキストと形を片づけるために、CLSを使いなさい。

OK, time to get a bit more complicated, lets introduce the RND() command first of all.
OKもう少し複雑になるために、RND()命令を導入する、 まず第一に。

Print rnd(10)
Print rnd(6)
Print rnd(15)
Print rnd(106)
Wait key

Remember that I told you, you can print numbers straight off without quotes, well here’s why, commands like RND() return numbers, not text (we will find out about data types in a later section).
私があなたに言ったことを思い出す、あなたは引用なしでまっすぐに数をプリントすることができる、ここになぜ、RND()命令の戻り値は数値です、テキストでない。(我々は、後のセクションでデータ型について知る)
RND() returns an integer (whole number) value between 0 and the number specified, so RND(3) with return 0,1,2 or 3 randomly.
RND()、 数が0から指定した整数の間、それで、ランダムの 0,1,2または3を返す、そうRND(3)。
Now, you may have run the program several times and are now thinking “Hey, the same numbers some up each time, that’s not random at all!”, and you’d be correct.
現在、あなたは何度かプログラムを実行するかもしれなくて、現在思っている、「おい、何度やっても、まったくランダムで無く同じ値を示す!」、そして、あなたは正しいだろう。
RND() is actually not random at all, in fact, computers can’t ever be completely random, but we can make it seem random enough for our purposes.
RND()、実際、まったくランダムでなく実はある、コンピュータは決して完全にランダムではありえない、しかし、我々はそれを我々の目的のために十分にランダムなようにさせることができる。

Randomize timer()
Print rnd(10)
Print rnd(6)
Print rnd(15)
Print rnd(106)
Wait key

Just like INK RGB(), this is actually 2 commands, just that the TIMER() command is acting as a value.
INK RGB()ような、これは実は2つの命令である、ちょうどそれ TIMER()命令は値の働きをしている。
RANDOMIZE sets the random seed, which is the number used to generate the random number.
RANDOMIZEは乱数の種を設定する、そしてそれは、数は乱数を生み出すのに用いられる。
So next time the computer needs to do the RND() function it passes the seed into another internal function to generate the random number.
そうコンピュータは、RND()をする必要がある、それが乱数を生み出すためにもう一つの内部の関数に種に渡す関数。
Like so…
so…のように

Random seed à FUNCTION à Output random number
ランダムな種 → 関数 → 出力乱数

Then the number generated is used as the random seed the next time RND() is called, so a completely different number will be generated.
それから、ランダムなものは次にRND()と呼ばれる種をまいて、発生する数が使われる、完全に異なる数が発生するように、。

We use TIMER() to set the seed as TIMER() returns the time in milliseconds (1000th of a second), and time is always changing.
我々はTIMER()を使う、TIMER()としての種をセットする、ミリ秒(1秒の第1000)と時間の戻りタイムは常に変わっている。
The seed is set when we execute the program, and it is very unlikely that every time we run the program the processor time will be exactly the same, to the millisecond, therefore the random number will be different.
我々がプログラムを実行するとき、種はまかれる、そして、我々がプログラムを実行するたびに、プロセッサー時間が正確に同じことであることは、非常にありそうもない、ためにミリ秒、したがって、乱数は異なる。

Anyway, back to drawing stuff.
とにかく、ものを描くことに戻りなさい。

Start:
Randomize timer()
Ink rgb(rnd(255),rnd(255),rnd(255)),0
Box 10,10,100,100
Set cursor 0,150
Print "Colour Value: ";
Print point(50,50)
Print
Print "Red Value: ";
Print rgbr(point(50,50))
Print
Print "Green Value: ";
Print rgbg(point(50,50))
Print
Print "Blue Value: ";
Print rgbb(point(50,50))
Wait key
cls
Goto start

“What!?!”
「なんと!?!」
I hear you say.
私は、あなたが言うのを聞く。
Well calm down, it’s not as complicated as it looks.
下ってかなり穏やかで、それはそれが見るほど複雑でない。
First of all there is a word “Start” with a colon after it.
まず第一に、語「スタート」が、それの後、コロンである。
This is known as a label and is neither a command nor a number.
これはラベルとして知られていて、命令でも数でもない。
It marks a point in your code where you can jump to using the GOTO command (see bottom).
あなたがどこにGOTO命令(底を見る)を使うことへジャンプすることができるかは、あなたのコードで点を評価する。

Next is the RANDOMIZE command with TIMER() as we have just seen.
次は、そうであるTIMER()によるRANDOMIZE命令、我々がちょうど今見えたように。
Next is the INK command setting the foreground colour using random colour values between 0 and 255.
次は、0と255の間でランダムなカラー値を使っている前景色をセットしているINK命令である。
Next we draw a box on the screen in the colour that was just randomly generated.
次に、我々はちょうどランダムに発生した色で、スクリーンで箱を描く。
Now, what if we want to know what colour the box is?
現在、我々が箱が何色かわかっていたいならば、どうですか?
Well, we need to find the colour values, and that’s why we use POINT().
さて、我々はカラー値を見つける必要がある、そして、そういうわけで、我々はPOINT()を使う。
This gets the colour value (the long confusing one that DBPro understands) at a specified 2D coordinate.
これは、指定された2Dのカラー値(DBProが理解する長い混乱させるもの)を同等にする。
We use the POINT() command somewhere in the centre of the box to find the colour, but now we have it, what use is it?
我々は POINT()を使う、色を見つけるために、箱の中心を命じなさい。ほんの我々がそれを持つ今、それはどんな使用であるか?
It’s too long an confusing!
それは、あまりに長い混同する!
That’s where RGBR(), RGBG() and RGBB() come in to play, they extract the colour values that we understand (from 0 to 255) from the long complicated value that DBPro understands.
それはそうであるどこでRGBR()、RGBG()、そして、RGBB()、遊ぶために中で来られて、それは我々がDBProが理解する長い複雑な値から理解する(0から255まで)カラー値を抽出する。
Kind of the opposite to RGB().
RGB()への正反対の種類。

So now we have printed all the data using a combination of PRINT “”, PRINT “”; and PRINT, and we have a wait key command.
それで、我々がプリントの組合せを使っている全てのデータをプリントした今、「「PRINT「;そして、プリントしなさい、そして、我々は待ちキー命令を持つ。
One a key is pressed the screen is cleared and we come across a GOTO command.
ひとつのキーを押すことでスクリーンがすっきりする、そして、我々はGOTO命令全体で来る。
This couldn’t be simpler, you write the name of the LABEL (without the colon) after the GOTO, and the computer jumps right back to the label and, in this case, starts all over again.
これはより単純ではありえなかった、あなたはGOTOの後、ラベル(コロンなしで)の名前を書く、そして、コンピュータはラベルへ正にジャンプして、この場合、はじめからもう一度動き出す。
Press the escape key to quit.
やめるために、エスケープ・キーを押しなさい。

Summary of Commands

命令の概要

· DOT x,y[,colour] - Draws a dot on the screen, you can optionally specify a colour (see RGB())
DOT x,y[, colour] - 画面の上の点を描く、あなたが色を任意に指定することができる(RGB()参照)

· BOX x1,y1,x2,y2[,col1,col2,col3,col4] - Draws a box on the screen, you can optionally supply the colour of all four corners
BOX x1,y1,x2,y2[, col1,col2,col3,col4] - 画面上に箱を描く、あなたが全4つの角の色を任意に設定することができる

· LINE x1,y1,x2,y2 - Draws a line on the screen
LINE x1,y1,x2,y2 - 線をスクリーンに描く

· CIRCLE x,y,radius - Draws a circle of specified radius on the screen
CIRCLE x,y,radius - 指定された半径の環をスクリーンに描く

· ELLIPSE x,y,radiusX,radiusY - Draws an ellipse of specified radiuses on the screen
ELLIPSE x,y,radiusX,radiusY - 指定された半径の楕円をスクリーンに描く

· RND(range) - Generates a pseudo random number from 0 to the number specified
RND(範囲)- 0から指定される数まで疑似乱数を生み出す

· RANDOMIZE - Sets the random seed for RND().
RANDOMIZE- RND()のための乱数の種をセットする。
Use in conjunction with TIMER() for best random effects
TIMER()とともに使用、最良のランダムな影響

· TIMER() - Gets the internal clock in milliseconds
TIMER()-ミリ秒の内部時計を得る

· POINT(x,y) - Gets the DBPro colour value of the pixel at the specified point.
POINT(x,y)- 指定された点のピクセルのDBPro色の値を得る。

· RGBR(col), RGBG(col) and RGBB(col) - Gets the separate red, blue and green colour values from a DBPro colour value.
RGBR()、RGBG()、そして、RGBB()-DBPro色値から別々の赤くて、青くて、緑のカラー値を得る。

· GOTO label - Jumps to the label specified.
GOTO・ラベル - 指定されるラベルへジャンプする。
Labels are words followed by a colon :
ラベルは、コロンが続く語である:

End of Section Tasks

セクション終わりの作業

l Make a program that keeps drawing random size circles at random positions on the screen in random colours.
ランダムな色でスクリーンのランダムな位置でランダムなサイズ円を描き続けるプログラムを行いなさい。