JP2630843B2 - Straight line drawing method and apparatus - Google Patents

Straight line drawing method and apparatus

Info

Publication number
JP2630843B2
JP2630843B2 JP1284001A JP28400189A JP2630843B2 JP 2630843 B2 JP2630843 B2 JP 2630843B2 JP 1284001 A JP1284001 A JP 1284001A JP 28400189 A JP28400189 A JP 28400189A JP 2630843 B2 JP2630843 B2 JP 2630843B2
Authority
JP
Japan
Prior art keywords
scan line
dot
straight line
dots
generated
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP1284001A
Other languages
Japanese (ja)
Other versions
JPH03144867A (en
Inventor
保彦 高橋
憲治 北村
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nippon Steel Corp
Original Assignee
Nippon Steel Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Steel Corp filed Critical Nippon Steel Corp
Priority to JP1284001A priority Critical patent/JP2630843B2/en
Publication of JPH03144867A publication Critical patent/JPH03144867A/en
Application granted granted Critical
Publication of JP2630843B2 publication Critical patent/JP2630843B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Image Generation (AREA)

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は、ドット式のプロッタ、プリンタ、ディスプ
レイ等における直線の描画方法及び装置に関するもので
ある。
Description: BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method and an apparatus for drawing a straight line on a dot type plotter, printer, display and the like.

〔従来の技術〕[Conventional technology]

プロッタ、ワードプロセッサ、パーソナルコンピュー
タ等を用いて図形処理を行う場合、図形をドットパター
ンにより表現しなければならない。このような装置のド
ットパターン形成面(仮想的なものであってよい。)に
直線のドットパターンを形成する従来の方法では、例え
ばX軸に対する傾斜角度dが0゜<d<45゜の直線を形
成する場合、第7図に示すように、確定したドットD
0(x1,y1)に対してX軸方向に1移動した点D1(x1+1,
y1)と、X軸方向及びY軸方向に夫々1移動した点D
2(x1+1,y1+1)を計算し、これらの点D1、D2と理想
直線lとの間の誤差を夫々求め、その誤差の小さい方の
点を描画点として確定して、そこにドットを発生させ
る。以下同様にして直線lを表現するためのドットパタ
ーンが形成される。
When performing graphic processing using a plotter, word processor, personal computer, or the like, the graphic must be represented by a dot pattern. In a conventional method of forming a linear dot pattern on a dot pattern formation surface (which may be virtual) of such an apparatus, for example, a straight line having an inclination angle d with respect to the X-axis of 0 ° <d <45 ° When forming a dot, as shown in FIG.
0 (x 1 , y 1 ), a point D 1 (x 1 +1
y 1 ) and a point D moved by one in the X-axis direction and one in the Y-axis direction
2 (x 1 +1, y 1 +1), the errors between these points D 1 , D 2 and the ideal straight line 1 are obtained, and the point with the smaller error is determined as the drawing point, Generate dots there. Hereinafter, a dot pattern for expressing the straight line 1 is formed in the same manner.

しかしながら、上述の方法では小数点以下の計算が大
変なので、これを改良した描画方法として、「Bresenha
mの線描画アルゴリズム」と呼ばれる方法が広く知られ
ている。この「Bresenhamの線描画アルゴリズム」につ
いては、図形処理情報センター出版の雑誌「PIXEL」No.
11の101〜107ページに記載されている。
However, in the above-mentioned method, the calculation after the decimal point is difficult, and as an improved drawing method, "Bresenha
A method called "m line drawing algorithm" is widely known. This "Bresenham's line drawing algorithm" is described in the magazine "PIXEL" No.
11 pages 101-107.

〔発明が解決しようとする課題〕[Problems to be solved by the invention]

上述の方法及び「Bresenhamの線描画アルゴリズム」
においては、いずれも、線を描画するのに1点ずつ計算
しなければならず、このため、描画時間が膨大になって
しまうという問題点があった。
The above method and "Bresenham's line drawing algorithm"
In each of the methods described above, it is necessary to calculate one point at a time to draw a line, and therefore, there is a problem that the drawing time becomes enormous.

これは、例えばマイクロプロセッサで描画点を計算し
て、画像メモリ(ビットマップメモリ)に書き込む場
合、マイクロプロセッサが所定のデータビット幅(例え
ば8ビットコンピュータでは8ビット、本明細書では
「ワード幅」と呼ぶ。)毎にデータの書き込み及び読み
出しを行なうにもかかわらず、描画点の計算は1ビット
毎に行われるため、その効率が極めて悪くなっていたか
らである。特に、ドットパターン形成面のX軸又はY軸
に対する傾きが小さい直線では、1つのワード幅内に多
数のドットを発生させる必要があるため、その効率が著
しく悪くなっていた。
This is because, for example, when a drawing point is calculated by a microprocessor and is written into an image memory (bitmap memory), the microprocessor uses a predetermined data bit width (for example, 8 bits in an 8-bit computer, and “word width” in the present specification). This is because, although writing and reading of data are performed every time, the calculation of the drawing point is performed for each bit, the efficiency is extremely low. In particular, in the case of a straight line having a small inclination of the dot pattern formation surface with respect to the X axis or the Y axis, it is necessary to generate a large number of dots within one word width, so that the efficiency has been extremely poor.

そこで本発明の課題は、描画速度を向上させた直線描
画方法及び装置を提供することである。
Accordingly, an object of the present invention is to provide a straight line drawing method and apparatus that improve the drawing speed.

〔課題を解決するための手段〕[Means for solving the problem]

本発明は、ドットパターン形成面のX軸とY軸のう
ち、形成すべき直線との間の傾きが小さい方の軸と平行
にスキャンラインを設定すれば、同一のスキャンライン
上に発生させるべきドットの数nは基本的にNとN+1
(NとN−1と考えてもよい。)の2種類しか存在しな
いという事実に基づいてなされたものである。
According to the present invention, if a scan line is set in parallel with the axis having the smaller inclination between the X-axis and the Y-axis of the dot pattern formation surface and the straight line to be formed, it should be generated on the same scan line. The number n of dots is basically N and N + 1
(N and N-1 may be considered.) This is based on the fact that only two types exist.

第4図及び第5図を用いてこの事実を説明する。第4
図は傾き3/10の直線を表現するためのドットパターンを
示したものであり、始点a及び終点bの近傍部分を除い
て同一水平スキャンライン上に発生させるドットの数は
3又は4である。また第5図は傾き7/30の直線のドット
パターンであり、同一水平スキャンライン上に発生させ
るドットの数は4又は5である。このように、直線描画
時に同一スキャンライン上に発生させるドットの数は、
小さい方の数をNとすれば、その始点及び終て近傍部分
を除き、NとN+1(大きい方の数をNとすれば、Nと
N−1)の2種類しか存在しない。
This fact will be described with reference to FIGS. 4th
The figure shows a dot pattern for expressing a straight line having a slope of 3/10, and the number of dots generated on the same horizontal scan line is 3 or 4 except for the vicinity of the start point a and the end point b. . FIG. 5 shows a linear dot pattern having a slope of 7/30, and the number of dots generated on the same horizontal scan line is four or five. Thus, the number of dots generated on the same scan line during straight line drawing is
Assuming that the smaller number is N, there are only two types, N and N + 1 (where N is the larger number, N and N-1) except for the start point and the end and the vicinity.

そこで本発明の直線描画方法においては、第1図に示
すように、 ドットパターン形成面を構成するドット発生点のマト
リックスの一辺に平行なスキャンラインを、そのスキャ
ンラインに垂直な方向に順次シフトさせて、前記ドット
パターン形成面上に所定の直線パターンを形成させるよ
うになし、 その際、形成すべき理想直線の前記スキャンラインに
対する傾きの逆数の整数部を、1つのスキャンライン上
に発生させる基本のドット数Nとして求め、 前記傾きの逆数の小数部を前記スキャンラインのシフ
ト毎に加算累積し、この累積値と所定値との比較結果か
ら、次のスキャンライン上に発生させるべきドットの数
nが前記NとN+1とのいずれであるか、又は、前記N
とN−1とのいずれであるかを判定し、 この判定結果に応じたドット数を、所定のワード幅に
対応して設けられたバッファレジスタ104に保持させ、 このバッファレジスタ104の内容を、前記ドット発生
点のマトリックスに対応して設けられたビットマップメ
モリ106に描画するようにしている。
Therefore, in the straight line drawing method of the present invention, as shown in FIG. 1, scan lines parallel to one side of a matrix of dot generation points constituting a dot pattern forming surface are sequentially shifted in a direction perpendicular to the scan lines. A predetermined straight line pattern is formed on the dot pattern forming surface. At this time, an integer part of a reciprocal of an inclination of an ideal straight line to be formed with respect to the scan line is generated on one scan line. The decimal part of the reciprocal of the inclination is added and accumulated for each shift of the scan line, and the number of dots to be generated on the next scan line is obtained from the comparison result between the accumulated value and a predetermined value. n is either N or N + 1, or N
And N−1, and the number of dots corresponding to the result of the determination is held in a buffer register 104 provided corresponding to a predetermined word width. The image is drawn in the bit map memory 106 provided corresponding to the matrix of the dot generation points.

そして上記方法に使用する本発明の直線描画装置は、 ドット発生点のマトリックスに対応したビットマップ
を有し、且つ、所定のワード幅単位で書き込み及び読み
出しが行われるビットマップメモリ106と、 前記ドット発生点のマトリックスの一辺に平行なスキ
ャンラインを、そのスキャンラインに垂直な方向にシフ
トさせるスキャンラインシフト手段107と、 形成すべき理想直線の前記スキャンラインに対する傾
きの逆数の整数部を、1つのスキャンライン上に発生さ
せる基本のドット数Nとして求める基本ドット数計算手
段101と、 前記傾きの逆数の小数部を前記スキャンラインのシフ
ト毎に加算累積し、この累積値と所定値との比較結果か
ら、次のスキャンライン上に発生させるべきドットの数
nが前記NとN+1とのいずれであるか、又は、前記N
とN−1とのいずれであるかを判定するドット数判定手
段102と、 ビットマップメモリ106の前記ワード幅に対応して設
けられたバッファレジスタ104と、 ドット数判定手段102による判定結果に応じたドット
数を前記バッファレジスタ104に保持させるドット数保
持手段103と、 バッファレジスタ104の内容をビットマップメモリ106
に描画する描画手段105とを有している。
The linear drawing apparatus of the present invention used in the above method has a bitmap memory 106 having a bitmap corresponding to a matrix of dot generation points, and writing and reading are performed in a predetermined word width unit. A scan line shift means 107 for shifting a scan line parallel to one side of the matrix of the generation point in a direction perpendicular to the scan line; and an integer part of the reciprocal of the inclination of the ideal straight line to be formed with respect to the scan line, Basic dot number calculating means 101 for calculating a basic dot number N to be generated on a scan line; and a decimal part of the reciprocal of the inclination is added and accumulated for each shift of the scan line, and a comparison result between the accumulated value and a predetermined value is obtained. From the above, whether the number n of dots to be generated on the next scan line is N or N + 1, and Is the N
And N−1, a buffer register 104 provided corresponding to the word width of the bitmap memory 106, Means for holding the number of dots in the buffer register 104, and a bitmap memory 106 for storing the contents of the buffer register 104.
And a drawing unit 105 that draws the image on the screen.

〔作用〕[Action]

本発明においては、まず、形成すべき理想直線の傾き
から、同一スキャンライン上に発生させるべきドットの
数Nを求め、一方、スキャンラインをシフトさせる毎
に、既に発生させたドットの位置と形成すべき理想直線
との間の誤差を累積して、その累積結果から、次のスキ
ャンライン上に発生させるべきドットの数nが前記Nと
N+1とのいずれであるか、又は、前記NとN−1との
いずれであるかを判定するようにしている。
In the present invention, first, the number N of dots to be generated on the same scan line is obtained from the inclination of the ideal straight line to be formed. On the other hand, every time the scan line is shifted, the position of the already generated dot and the formation of the dot are determined. The error between the ideal line to be accumulated is accumulated, and the accumulation result indicates whether the number n of dots to be generated on the next scan line is N or N + 1, or N and N + 1. -1 is determined.

従って、その判定結果に基づいて、1つのスキャンラ
イン上に複数個のドットを同時に発生させることができ
るようになり、このため、所定のワード幅単位で行われ
るビットマップメモリ106への書き込みを効率よく行う
ことができて、描画速度が向上する。
Therefore, a plurality of dots can be simultaneously generated on one scan line based on the result of the determination, and the writing to the bitmap memory 106 performed in a predetermined word width unit can be efficiently performed. It can be performed well, and the drawing speed is improved.

〔実施例〕〔Example〕

以下、本発明を実施例につき図面を参照して説明す
る。
Hereinafter, embodiments of the present invention will be described with reference to the drawings.

第2図は本発明の一実施例による直線描画装置の構成
を示すブロック図である。
FIG. 2 is a block diagram showing a configuration of a straight line drawing apparatus according to one embodiment of the present invention.

この直線描画装置は、中央処理装置(CUP)1、マイ
クロプログラムが格納されたROM2、ビットマップメモリ
3、このビットマップメモリ3のビットマップに対応す
る例えば第4図に示すドットパターン形成面のY軸方向
の位置を決定するためのカウンタ4、上記ドットパター
ン形成面のX軸方向の位置を計算するためのX座標位置
決定用アキュムレータ(X−ACC)5、データバス6、
及び、プロッタ等の出力装置7との間のインターフェー
ス(I/O)8を有している。そしてCPU1は演算部(ALU)
11と、バッファレジスタの機能を具備するドット発生用
のアキュムレータ(ACC)12とを有している。
This straight line drawing apparatus includes a central processing unit (CUP) 1, a ROM 2 storing a microprogram, a bit map memory 3, and a Y corresponding to a dot pattern formation surface shown in FIG. A counter 4 for determining the position in the axial direction, an accumulator (X-ACC) 5 for determining an X coordinate position for calculating the position in the X-axis direction of the dot pattern forming surface, a data bus 6,
Further, an interface (I / O) 8 with an output device 7 such as a plotter is provided. And CPU1 is an arithmetic unit (ALU)
11 and an accumulator (ACC) 12 for generating dots, which has the function of a buffer register.

以下の説明では、第4図及び第5図に示すような横
(X軸方向)32ドット、縦(Y軸方向)16ドットのドッ
トパターン形成面に直線描画を行うものとする。そして
本実施例の場合、ビットマップメモリ3は8ビットづつ
アクセスされるため、第4図及び第5図に示すように、
32×16ドットのドットパターン形成面はX軸方向に4つ
に分割され、A列、B列、C列、D列の順に“0000"か
ら“003F"までの64個のアドレスがビットマップメモリ
3内に割り当てられている(第6図参照)。そして第4
図の例では、始点(0,0)から終点(30,9)に直線を描
いており、第5図の例では、始点(0,0)から終点(30,
7)に直線を描いている。
In the following description, it is assumed that straight lines are drawn on a dot pattern forming surface of 32 dots in the horizontal direction (X-axis direction) and 16 dots in the vertical direction (Y-axis direction) as shown in FIGS. In this embodiment, since the bit map memory 3 is accessed every 8 bits, as shown in FIG. 4 and FIG.
The dot pattern forming surface of 32 × 16 dots is divided into four in the X-axis direction, and 64 addresses from “0000” to “003F” are stored in the bit map memory in the order of row A, row B, row C and row D. 3 (see FIG. 6). And the fourth
In the example of the figure, a straight line is drawn from the start point (0,0) to the end point (30,9). In the example of FIG. 5, the start point (0,0) is drawn to the end point (30,9).
7) A straight line is drawn.

次に、本実施例の直線描画方法を、CPU1の動作を示す
第3図のフローチャートに従って説明する。
Next, the straight line drawing method of the present embodiment will be described with reference to the flowchart of FIG.

まず演算部11により、描画すべき直線の傾きΔy/Δx
から基本ドット数Nが計算される。本実施例において
は、この基本ドット数Nは次式から求められる。
First, the calculation unit 11 calculates the inclination Δy / Δx of the straight line to be drawn.
Is used to calculate the basic dot number N. In this embodiment, the basic dot number N is obtained from the following equation.

N=INT(Δx/Δy) ……(1) 即ち、直線の傾きΔy/Δxの逆数の整数部が基本ドッ
ト数Nになる。第4図の例では、直線の傾きが3/10であ
るのでNは3となる。また第5図の例では傾きが7/30で
あるのでNは4となる。
N = INT (Δx / Δy) (1) That is, the integer part of the reciprocal of the slope Δy / Δx of the straight line is the basic dot number N. In the example of FIG. 4, since the inclination of the straight line is 3/10, N is 3. In the example of FIG. 5, since the inclination is 7/30, N is 4.

次に、直線の始点部分の描画、即ち最初のスキャンラ
イン上でのドット発生を行う。本実施例においては、ス
キャンラインをドットパターン形成面のX軸と平行に設
定しており、第4図及び第5図の例では、いずれも始点
aが(0,0)であるので、ドット発生を行う最初のスキ
ャンラインはy=0のスキャンラインである。この始点
描画及び後の終点描画は、直線の始点近傍部分及び終点
近傍部分では、同一スキャンライン上に発生させるべき
ドットの数nは上記基本ドット数NとN+1とのいずれ
かであるという基本法則が成り立たないために、別に行
う必要がある。
Next, drawing of a starting point of a straight line, that is, dot generation on the first scan line is performed. In this embodiment, the scan line is set parallel to the X axis of the dot pattern forming surface. In the examples of FIGS. 4 and 5, the starting point a is (0, 0), The first scan line to be generated is the scan line at y = 0. In the start point drawing and the subsequent end point drawing, the basic rule that the number n of dots to be generated on the same scan line is one of the basic dot number N and N + 1 in the vicinity of the start point and the end point of the straight line. Does not hold, so it must be done separately.

この最初のスキャンライン上へのドット発生は、描画
すべき理想直線lのy座標が次のスキャンラインの方に
近くなるまで、即ち、第4図及び第5図の例ではy=0.
5を越えるまで行わなければならない。その個数nは、
Δx/2Δyが割り切れない場合、 n=INT(Δx/2Δy)+1 ……(2) Δx/2Δyが割り切れる場合、 n=Δx/2Δy ……(2)′ となる。第4図の例ではn=2、第5図の例ではn=3
である。
The dots are generated on the first scan line until the y coordinate of the ideal straight line 1 to be drawn becomes closer to the next scan line, that is, y = 0 in the examples of FIGS.
You must do it until you exceed 5. The number n is
When Δx / 2Δy is not divisible, n = INT (Δx / 2Δy) +1 (2) When Δx / 2Δy is divisible, n = Δx / 2Δy (2) ′. In the example of FIG. 4, n = 2, and in the example of FIG. 5, n = 3.
It is.

そこで、例えば第4図の例では、(0,0)と(1,0)の
点にドットを発生させるために、第2図のドット発生用
アキュムレータ(ACC)12にドット数のデータを反映し
たコード“11000000"を発生させ、これを、ビットマッ
プメモリ3の直線の始点が存在するアドレス“0000"に
転送、即ちビットマップメモリ3に描画する(第6図参
照)。このドット発生用アキュムレータ(ACC)12に発
生させるコードのLSBが“0"になった時点で、そのスキ
ャンライン上でのドット発生が終了したことになるの
で、第2図のカウンタ4によりy=y+1として、スキ
ャンラインを1シフトさせ、次のスキャンライン上での
ドット発生を行う。
Thus, for example, in the example of FIG. 4, in order to generate dots at the points (0,0) and (1,0), the data of the number of dots is reflected in the dot generation accumulator (ACC) 12 of FIG. The generated code "11000000" is generated and transferred to the address "0000" where the start point of the straight line exists in the bitmap memory 3, that is, drawn in the bitmap memory 3 (see FIG. 6). When the LSB of the code generated by the dot generation accumulator (ACC) 12 becomes "0", it means that the dot generation on the scan line has been completed, and the counter 4 shown in FIG. As y + 1, the scan line is shifted by one, and a dot is generated on the next scan line.

y=1以降のスキャンライン上でのドット発生を行う
ためには、そのスキャンライン上に発生させるべきドッ
トの数nが基本ドット数NとN+1とのいずれであるか
を決定しなければならない。
In order to generate dots on a scan line after y = 1, it is necessary to determine whether the number n of dots to be generated on the scan line is the basic dot number N or N + 1.

基本ドット数Nを上記(1)式のように定義した場
合、発生させたドット位置と理想直線lとの間の誤差と
して累積されるのはΔx/Δyの小数部である。そこで、
演算部11では、スキャンラインを1変化させる毎にこの
Δx/Δyの小数部を加算していき、その値が1.0を越え
るまではn=Nとし、1.0を越えた時点でn=N+1と
する。
When the basic dot number N is defined as in the above equation (1), it is the decimal part of Δx / Δy that is accumulated as an error between the generated dot position and the ideal straight line l. Therefore,
The arithmetic unit 11 adds the decimal part of Δx / Δy every time the scan line is changed by 1, and sets n = N until the value exceeds 1.0, and sets n = N + 1 when the value exceeds 1.0. .

具体的には、y=0.5のときの、 の値を判定変数Eの初期値として用い、また、理想直線
lとの間の誤差を、 G=G1=(Δx/Δy)−N ……(4) として、スキャンラインを1変化させる毎に上記判定変
数Eに誤差G1を加算していく。そして、この判定変数E
が1を越えるまでは、そのスキャンライン上に発生させ
るドット数nとして基本ドット数Nを出力し、Eが1を
越えた時点でn=N+1とする。
Specifically, when y = 0.5, Is used as an initial value of the judgment variable E, and an error between the ideal straight line 1 and G is defined as G = G 1 = (Δx / Δy) −N (4). going by adding error G 1 in the determination variable E in. Then, this determination variable E
Until E exceeds 1, the basic dot number N is output as the number n of dots to be generated on the scan line, and when E exceeds 1, n = N + 1.

E>1となった後は、誤差Gを、 G=G2=(Δx/Δy)−N−1 ……(5) とし、スキャンラインを1変化させる毎に判定変数Eに
今度は誤差G2を加算していく。そして、E>1の間はそ
のスキャンライン上に発生させるドット数nとしてN+
1を出力し、Eが1よりも小さくなった時点で誤差Gを
G1に戻す。
After E> 1, the error G is set as follows: G = G 2 = (Δx / Δy) −N−1 (5), and each time the scan line is changed by one, the error G Add 2 During E> 1, N + is set as the number n of dots generated on the scan line.
1 is output, and when E becomes smaller than 1, the error G is
Back to the G 1.

即ち、判定変数Eが1よりも小さい間は、その判定変
数Eが1を越えるまで、スキャンラインを1変化させる
ごとに判定変数Eに誤差としてG1を加算するとともに、
そのスキャンライン上に発生させるべきドットの数nを
Nと判定し続け、一方、判定変数Eが1よりも大きい間
は、その判定変数変数Eが下回るまで、スキャンライン
を1変化させるごとに判定変数Eに誤差としてG2を加算
するとともに、そのスキャンライン上に発生させるべき
ドットの数nをN+1と判定し続ける。
That is, while the judgment variable E is smaller than 1 , G1 is added to the judgment variable E as an error every time the scan line is changed by 1 until the judgment variable E exceeds 1, and
While the number n of dots to be generated on the scan line is continuously determined to be N, while the determination variable E is greater than 1, the determination is made every time the scan line is changed by 1 until the determination variable E falls below 1. with adding G 2 as an error variable E, it continues to determine the number n of dots to be generated on the scan line n + 1 and.

この方法に従えば、第4図の例において、y=1のス
キャンライン上に発生させるドット数は基本ドット数3
であるので、第2図のドット発生用アキュムレータ(AC
C)12にコード“00111000"を発生させ、これを、ビット
マップメモリ3のアドレス“0004"に転送する(第6図
参照)。このとき、ドット発生用アキュムレータ(AC
C)12に発生させるコードにおいて、“1"の立ち上がる
ビット位置(y=1のスキャンライン上では左から3ビ
ット目)は、X軸方向における発生ドット数を累積し
て、その位置を計算するためのX座標位置決定用アキュ
ムレータ(X−ACC)5を用いて決定される。即ち、こ
のX座標位置決定用アキュムレータ(X−ACC)5にお
いて、既に発生させたドットの数を累積し、その累積値
をワード幅(本実施例の場合には8)で割った余剰Rの
次のビット位置を、ドット発生用アキュムレータ(AC
C)12における“1"の立ち上がるビット位置としてCPU1
により決定する。
According to this method, in the example of FIG. 4, the number of dots generated on the scan line with y = 1 is the basic dot number 3
Therefore, the accumulator for generating dots shown in FIG. 2 (AC
C) A code "00111000" is generated in 12 and transferred to an address "0004" in the bit map memory 3 (see FIG. 6). At this time, the dot generation accumulator (AC
C) In the code generated in 12, the bit position where “1” rises (the third bit from the left on the scan line with y = 1) is calculated by accumulating the number of generated dots in the X-axis direction. Is determined using an X-coordinate position accumulator (X-ACC) 5. That is, in the X-coordinate position determining accumulator (X-ACC) 5, the number of already generated dots is accumulated, and the accumulated value is divided by the word width (8 in the present embodiment) to obtain a surplus R. The next bit position is stored in the accumulator for dot generation (AC
C) As the bit position where “1” rises in 12, CPU1
Determined by

既述したy=0のスキャンラインの場合と同様、この
y=1のスキャンラインにおいても、ドット発生用アキ
ュムレータ(ACC)12に発生させるコードのLSBが“0"に
なった時点で、このスキャンライン上でのドット発生が
終了したことになるので、第2図のカウンタ4によりy
=y+1として、スキャンラインをシフトさせ、次に、
y=2のスキャンライン上でのドット発生を行う。
As in the case of the scan line of y = 0, as described above, even in the scan line of y = 1, when the LSB of the code generated in the accumulator (ACC) 12 for dot generation becomes "0", this scan Since the dot generation on the line has been completed, the counter 4 shown in FIG.
= Y + 1 and shift the scan line, then
A dot is generated on a scan line of y = 2.

スキャンラインがy=2に移動した時点で判定変数E
が1を越えるので、このy=2のスキャンライン上に発
生させるべきドットの数は3+1=4となる。そこでド
ット発生用アキュムレータ(ACC)12に“1"を4個立て
ようとするが、この場合、X座標位置決定用アキュムレ
ータ(X−ACC)5により決定される“1"の立ち上がり
ビット位置がLSBから3ビット目になるので、4個の
“1"を立てることができない。そこでドット発生用アキ
ュムレータ(ACC)12に、まず3個の“1"からなるコー
ド"00000111"を発生させ、第6図に示すように、これ
を、ビットマップメモリ3のアドレス“0008"に転送す
る。そして、その時点で、直線の描画位置がX軸方向に
移動してB列の領域に入ったと判断し、残りの1ビット
のみを“1"としたコード“10000000"をドット発生用ア
キュムレータ(ACC)12に発生させ、これを、ビットマ
ップメモリ3のアドレス“0009"に転送する。
When the scan line moves to y = 2, the decision variable E
Exceeds 1, the number of dots to be generated on this y = 2 scan line is 3 + 1 = 4. Therefore, four "1" s are set in the dot generation accumulator (ACC) 12. In this case, the rising bit position of the "1" determined by the X coordinate position determination accumulator (X-ACC) 5 is LSB. , The third bit cannot be set. Therefore, a code "00000111" consisting of three "1" s is first generated in the dot generation accumulator (ACC) 12, and this is transferred to the address "0008" of the bit map memory 3 as shown in FIG. I do. At this point, it is determined that the drawing position of the straight line has moved in the X-axis direction and has entered the area of column B, and the code “10000000” with only the remaining one bit set to “1” is assigned to the dot generation accumulator (ACC ) 12 and transfers this to the address “0009” of the bit map memory 3.

そして、ここでドット発生用アキュムレータ(ACC)1
2に発生させたコードのLSBが“0"となるので、このスキ
ャンライン上での直線描画が終了したと判断し、次のス
キャンライン上での直線描画に移る。この時、判定変数
Eに加算する誤差はG2になっている。
And here the accumulator for dot generation (ACC) 1
Since the LSB of the code generated in step 2 is "0", it is determined that the straight line drawing on this scan line has been completed, and the process proceeds to the straight line drawing on the next scan line. At this time, the error to be added to the determination variable E is in the G 2.

スキャンラインがy=3に移動した時には、判定変数
Eが1を下回るので、発生ドット数nは基本ドット数3
となる。そして、上記と同様にして所定位置にドットを
発生させた後、更にスキャンラインを移動させる。この
時、判定変数Eに加算する誤差はG1になっている。
When the scan line moves to y = 3, the number n of generated dots is 3
Becomes Then, after generating dots at predetermined positions in the same manner as described above, the scan line is further moved. At this time, the error to be added to the determination variable E is in the G 1.

以下同様にして、ビットマップメモリ3のアドレス
“0026"までドットを発生させ、終点描画ステップに入
る。
In the same manner, dots are generated up to the address “0026” of the bitmap memory 3 and the process enters the end point drawing step.

この終点描画ステップは、発生させるドット位置が終
点座標に達したかどうきを判断し、達している場合に
は、そのスキャンライン上に発生させるべきドット数n
の如何にかかわらず、ドット発生位置を終点座標位置で
クリップすることにより行うことができる。
This end point drawing step determines whether the dot position to be generated has reached the end point coordinates, and if so, the number n of dots to be generated on the scan line
Irrespective of the above, it can be performed by clipping the dot generation position at the end point coordinate position.

以上の動作により、例えば第4図に示すようなドット
パターン形成面に直線を描画するためのドットパターン
がビットマップメモリ3内に格納される。
By the above operation, for example, a dot pattern for drawing a straight line on the dot pattern forming surface as shown in FIG. 4 is stored in the bitmap memory 3.

上述したように、本実施例においては、バッファレジ
スタとしての機能を具備するドット発生用アキュムレー
タ(ACC)12のワード幅単位で一度にドットを発生させ
ることができるので、CPU1の演算部(ALU)11での計算
効率が良くなり、描画速度が向上する。
As described above, in the present embodiment, dots can be generated at a time in units of the word width of the dot generation accumulator (ACC) 12 having a function as a buffer register. Therefore, the arithmetic unit (ALU) of the CPU 1 The calculation efficiency in step 11 is improved, and the drawing speed is improved.

なお、上述の実施例では、ドットパターン形成面のX
軸に対する傾斜角度dが0゜<d<45゜の直線を描画す
る場合を説明したが、それ以外の直線の場合にも、ほぼ
同様の構成によって描画することができる。その場合に
は、第1図の基本ドット数計算手段101の前段に、描画
すべき直線の傾きを識別するための傾き識別手段と、こ
の傾き識別手段により識別された直線の傾きに応じて適
当に座標変換を行うための座標変換手段を設ければよ
い。例えば、描画すべき直線の傾斜角度dが45゜<d<
90゜の場合には、座標変換手段によりx=y、y=xの
座標変換を行った後、上述の実施例と同じ手順でドット
発生及びビットマップメモリへの書き込みを行い、この
ビットマップメモリから読み出して出力する際に、再び
座標変換手段によりx=y、y=xの座標変換を行っ
て、座標系を元に戻せばよい。或いは、ビットマップメ
モリへの書き込みを行う際に、座標系を元に戻してもよ
い。同様に、−45゜<d<0゜の場合には、y=−yの
座標変換を行えばよく、また、−90゜<d<45゜の場合
には、x=−y、y=xの座標変換を行えばよい。
In the above-described embodiment, X in the dot pattern forming surface
The case where a straight line having an inclination angle d with respect to the axis of 0 ° <d <45 ° is described, but other straight lines can also be drawn by using a substantially similar configuration. In such a case, a slope identifying means for identifying the slope of a straight line to be drawn is provided before the basic dot number calculating means 101 in FIG. May be provided with coordinate conversion means for performing coordinate conversion. For example, the inclination angle d of a straight line to be drawn is 45 ° <d <
In the case of 90 °, after the coordinate conversion of x = y and y = x is performed by the coordinate conversion means, dot generation and writing to the bitmap memory are performed in the same procedure as in the above-described embodiment. When reading and outputting from the coordinate system, the coordinate conversion means may perform x = y and y = x coordinate conversion again to restore the coordinate system. Alternatively, the coordinate system may be restored when writing to the bitmap memory. Similarly, when −45 ° <d <0 °, the coordinate conversion of y = −y may be performed, and when −90 ° <d <45 °, x = −y and y = What is necessary is just to perform coordinate conversion of x.

なお、上記実施例の方法では、d=0゜及びd=90゜
の直線は描画することができない(基本ドット数Nの計
算ができないため)が、その場合でも、上述した直線の
傾き識別手段を用いれば、その直線を描画することがで
きる。例えば、傾き識別手段により直線の傾きがd=0
゜又はd=90゜であることを識別したならば、その直線
の任意の点のy座標又はx座標を求め、その座標に基づ
いて、Y軸又はY軸に平行な特定のスキャンライン上の
始点及び終点間の全てのドット発生点にドットを発生さ
せればよい。
In the method of the above embodiment, the straight line of d = 0 ° and d = 90 ° cannot be drawn (because the basic dot number N cannot be calculated). Is used, the straight line can be drawn. For example, the inclination of the straight line is d = 0 by the inclination identification means.
If it is determined that ゜ or d = 90 °, the y-coordinate or x-coordinate of any point on the straight line is obtained, and based on the coordinates, the Y-axis or a specific scan line parallel to the Y-axis is determined. A dot may be generated at all dot generation points between the start point and the end point.

本発明の方法及び装置は、あらゆる種類のドット式プ
ロッタ、プリンタ、ディスプレイ等に適用が可能であ
る。その場合、ドットパターン形成面は実際に存在して
いる必要はなく、ビットマップメモリ内に展開された仮
想的な概念であってよい。また、液晶ディスプレイ等の
ディスプレイ装置に本発明を適当する場合には、そのデ
ィスプレイ装置の各画素を1つのドットとみなして、本
発明を適用すればよい。
The method and apparatus of the present invention are applicable to all types of dot plotters, printers, displays, and the like. In that case, the dot pattern formation surface does not need to actually exist, and may be a virtual concept developed in the bitmap memory. When the present invention is applied to a display device such as a liquid crystal display, the present invention may be applied by regarding each pixel of the display device as one dot.

〔発明の効果〕〔The invention's effect〕

本発明の方法及び装置によれば、直線の描画処理速度
を、上来のものよりも速くすることができる。特に、従
来処理速度が極めて遅かった一方の軸に対して傾きの小
さい直線ほど、その効果は顕著である。
According to the method and apparatus of the present invention, the processing speed for drawing straight lines can be made faster than that of the conventional method. In particular, the effect is more remarkable on a straight line having a smaller inclination with respect to one axis in which the processing speed is extremely slow in the past.

また、本発明の方法及び装置によって直線を描画する
に当たっては、理想直線のスキャンラインに対する傾き
を求める際に、除算演算は1回行うだけでよいので、除
算演算を2回以上行わなければならない方式と比較し
て、演算ステップ数を少なくすることができ、高速での
直線描画が可能になる。この結果、例えば多くの直線要
素の集合として表面されたイメージデータを極めて短時
間で描くことができる。
In addition, when a straight line is drawn by the method and the apparatus of the present invention, the division operation only needs to be performed once when the inclination of the ideal line with respect to the scan line is obtained, so that the division operation must be performed twice or more. The number of calculation steps can be reduced as compared with, and high-speed straight line drawing becomes possible. As a result, for example, image data exposed as a set of many linear elements can be drawn in an extremely short time.

【図面の簡単な説明】[Brief description of the drawings]

第1図は本発明の基本構成を示すブロック図、第2図は
本発明の一実施例による直線描画装置の構成を示すブロ
ック図、第3図は第2図のCPUの動作を示すフローチャ
ート、第4図及び第5図は直線描画の実例を示す概念
図、第6図はビットマップメモリの内容を示す説明図、
第7図は従来の直線描画方法を示す説明図である。 なお、図面に用いた符号において、 1……CPU、3……ビットマップメモリ、4……カウン
タ、5……X座標位置決定用アキュムレータ(X−AC
C)、11……演算部(ALU)、12……ドット発生用アキュ
ムレータ(ACC、バッファレジスタ)、101……基本ドッ
ト数計数手段、102……ドット数判定手段、103……ドッ
ト発生手段(ドット数保持手段)、104……バッファレ
ジスタ、105……転送手段(描画手段)、106……ビット
マップメモリ、107……スキャンラインシフト手段
FIG. 1 is a block diagram showing a basic configuration of the present invention, FIG. 2 is a block diagram showing a configuration of a straight line drawing apparatus according to an embodiment of the present invention, FIG. 3 is a flowchart showing an operation of a CPU in FIG. 4 and 5 are conceptual diagrams showing an example of straight line drawing, FIG. 6 is an explanatory diagram showing the contents of a bitmap memory,
FIG. 7 is an explanatory view showing a conventional straight line drawing method. In the reference numerals used in the drawings, 1... CPU, 3... Bitmap memory, 4... Counter, 5... X-coordinate position determining accumulator (X-AC
C), 11 calculation unit (ALU), 12 dot accumulator (ACC, buffer register), 101 basic dot number counting means, 102 dot number determination means, 103 dot generation means ( Dot number holding means), 104 buffer register, 105 transfer means (drawing means), 106 bitmap memory, 107 scan line shift means

Claims (2)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】ドット発生点がマトリックス状に配列され
たドットパターン形成面にドットによる直線パターンを
形成させる直線描画方法において、 前記ドット発生点のマトリックスの一辺に平行なスキャ
ンラインを、そのスキャンラインに垂直な方向に順次シ
フトさせて前記直線パターンを形成させるようになし、 その際、形成すべき理想直線の前記スキャンラインに対
する傾きの逆数の整数部を、1つのスキャンライン上に
発生させる基本のドット数Nとして求め、 前記傾きの逆数の小数部を前記スキャンラインのシフト
毎に加算累積し、この累積値と所定値との比較結果か
ら、次のスキャンライン上に発生させるべきドットの数
nが前記NとN+1とのいずれであるか、又は、前記N
とN−1とのいずれであるかを判定し、 この判定結果に応じたドット数を、所定のワード幅に対
応して設けられたバッファレジスタに保持させ、 このバッファレジスタの内容を、前記ドット発生点のマ
トリックスに対応して設けられたビットマップメモリに
描画することを特徴とする直線描画方法。
1. A straight line drawing method for forming a linear pattern of dots on a dot pattern forming surface in which dot generation points are arranged in a matrix, wherein a scan line parallel to one side of a matrix of the dot generation points is formed by the scan line The linear pattern is formed by sequentially shifting in a direction perpendicular to the scan line. At this time, an integer part of a reciprocal of an inclination of the ideal straight line to be formed with respect to the scan line is generated on one scan line. The number of dots to be generated on the next scan line is obtained from the result of comparison between the accumulated value and a predetermined value. Is either N or N + 1, or N
And N−1, and the number of dots corresponding to the result of the determination is held in a buffer register provided corresponding to a predetermined word width. A straight line drawing method characterized by drawing in a bit map memory provided corresponding to a matrix of occurrence points.
【請求項2】ドット発生点のマトリックスに対応したビ
ットマップを有し、且つ、所定のワード幅単位で書き込
み及び読み出しが行われるビットマップメモリと、 前記ドット発生点のマトリックスの一辺に平行なスキャ
ンラインを、そのスキャンラインに垂直な方向にシフト
させるスキャンラインシフト手段と、 形成すべき理想直線の前記スキャンラインに対する傾き
の逆数の整数部を、1つのスキャンライン上に発生させ
る基本のドット数Nとして求める基本ドット数計算手段
と、 前記傾きの逆数の小数部を前記スキャンラインのシフト
毎に加算累積し、この累積値と所定値との比較結果か
ら、次のスキャンライン上に発生させるべきドットの数
nが前記NとN+1とのいずれであるか、又は、前記N
とN−1とのいずれであるかを判定するドット数判定手
段と、 前記ビットマップメモリの前記ワード幅に対応して設け
られたバッファレジスタと、 前記ドット数判定手段による判定結果に応じたドット数
を前記バッファレジスタに保持させるドット数保持手段
と、 前記バッファレジスタの内容を前記ビットマップメモリ
に描画する描画手段とを有することを特徴とする直線描
画装置。
2. A bit map memory having a bit map corresponding to a matrix of dot generation points and performing writing and reading in units of a predetermined word width, and a scan parallel to one side of the matrix of the dot generation points. A scan line shift means for shifting a line in a direction perpendicular to the scan line; and a basic dot number N for generating an integer part of a reciprocal of an inclination of the ideal straight line to be formed with respect to the scan line on one scan line. A basic dot number calculating means, and a decimal part of the reciprocal of the inclination is added and accumulated for each shift of the scan line, and a dot to be generated on the next scan line is obtained from a comparison result between the accumulated value and a predetermined value. Is the number n of the N or N + 1, or
And N−1, a buffer register provided corresponding to the word width of the bit map memory, and a dot according to the determination result by the dot number determining unit. A straight line drawing apparatus comprising: a dot number holding unit that holds a number in the buffer register; and a drawing unit that draws the content of the buffer register in the bitmap memory.
JP1284001A 1989-10-31 1989-10-31 Straight line drawing method and apparatus Expired - Fee Related JP2630843B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP1284001A JP2630843B2 (en) 1989-10-31 1989-10-31 Straight line drawing method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP1284001A JP2630843B2 (en) 1989-10-31 1989-10-31 Straight line drawing method and apparatus

Publications (2)

Publication Number Publication Date
JPH03144867A JPH03144867A (en) 1991-06-20
JP2630843B2 true JP2630843B2 (en) 1997-07-16

Family

ID=17673009

Family Applications (1)

Application Number Title Priority Date Filing Date
JP1284001A Expired - Fee Related JP2630843B2 (en) 1989-10-31 1989-10-31 Straight line drawing method and apparatus

Country Status (1)

Country Link
JP (1) JP2630843B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2776347B2 (en) * 1995-11-29 1998-07-16 日本電気株式会社 Drawing device for printer
JP4596678B2 (en) * 2001-05-15 2010-12-08 パナソニック株式会社 Line drawing device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6292077A (en) * 1985-10-18 1987-04-27 Fujitsu Ltd Pattern generating system

Also Published As

Publication number Publication date
JPH03144867A (en) 1991-06-20

Similar Documents

Publication Publication Date Title
EP0344686B1 (en) Clipping process and processor
KR940001880B1 (en) Method and apparatus for image processing
JP3037854B2 (en) Character generation method and device
JPH0640259B2 (en) Data processing device
JP2630843B2 (en) Straight line drawing method and apparatus
JP3009525B2 (en) Vector image drawing equipment
JP2634851B2 (en) Image processing device
JP2770582B2 (en) Figure filling device
JP3264619B2 (en) Image processing apparatus and method
JP2757614B2 (en) Figure filling device
EP0062669A1 (en) Graphic and textual image generator for a raster scan display.
JP3034140B2 (en) Character generation method and device
JPS63137378A (en) Graphics processing system
JP2000242802A (en) Graphic processor
JP2605609B2 (en) Dot display processing device
JP3072756B2 (en) Drawing equipment
JP2903514B2 (en) High-speed drawing method
JP2835056B2 (en) High quality character pattern generation method
JP2637921B2 (en) Character symbol generator
JP2804651B2 (en) Outline filling method
JP3057963B2 (en) Data converter
JP3347756B2 (en) Character generation method and device
JPH0439782A (en) Painting-out device for graphic
JPS59180777A (en) System for rotation processing of graphic data
JPH07334695A (en) Plotter and line width determining method

Legal Events

Date Code Title Description
LAPS Cancellation because of no payment of annual fees