JPH03144867A - Method and device for plotting straight line - Google Patents
Method and device for plotting straight lineInfo
- Publication number
- JPH03144867A JPH03144867A JP28400189A JP28400189A JPH03144867A JP H03144867 A JPH03144867 A JP H03144867A JP 28400189 A JP28400189 A JP 28400189A JP 28400189 A JP28400189 A JP 28400189A JP H03144867 A JPH03144867 A JP H03144867A
- Authority
- JP
- Japan
- Prior art keywords
- scan line
- dots
- straight line
- dot
- 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.)
- Granted
Links
Landscapes
- Image Generation (AREA)
Abstract
Description
【発明の詳細な説明】
(産業上の利用分野〕
本発明は、ドツト式のプロッタ、プリンタ、デイスプレ
ィ等における直線の描画方法及び装置に関するものであ
る。DETAILED DESCRIPTION OF THE INVENTION (Field of Industrial Application) The present invention relates to a method and apparatus for drawing straight lines in dot-type plotters, printers, displays, etc.
ブロック、ワードプロセッサ、パーソナルコンピュータ
等を用いて図形処理を行う場合、図形をドツトパターン
により表現しなければならない。When performing graphical processing using blocks, word processors, personal computers, etc., the graphic must be expressed as a dot pattern.
このような装置のトンドパターン形成面(仮想的なもの
であってよい、)に直線のドツトパターンを形成する従
来の方法では、例えばX軸に対する傾斜角度dが0”<
d<45°の直線を形成する場合、第7図に示すように
、確定したドツトD0(x、、y、)に対してX軸方向
に1移動した点DI (XI +1.)’l )と、X
軸方向及びY軸方向に夫々1移動した点D2 (XI
十t、 y+ +1)を計算し、これらの点D+、
Dzと理想直線lとの間の誤差を夫々求め、その誤差の
小さい方の点を描画点として確定して、そこにドツトを
発生させる。以下同様にして直線lを表現するためのド
ツトパターンが形成される。In the conventional method of forming a straight dot pattern on the dot pattern forming surface (which may be virtual) of such an apparatus, for example, the inclination angle d with respect to the X axis is 0''<
When forming a straight line with d<45°, as shown in Fig. 7, a point DI (XI +1.)'l) is moved by one point in the X-axis direction with respect to the determined dot D0(x,,y,). and X
Point D2 (XI
10t, y+ +1), and these points D+,
The error between Dz and the ideal straight line l is determined, the point with the smaller error is determined as a drawing point, and a dot is generated there. Thereafter, a dot pattern for representing the straight line 1 is formed in the same manner.
しかしながら、上述の方法では小数点以下の計算が大変
なので、これを改良した描画方法として、r Bres
enharaの線描画アルゴリズムjと呼ばれる方法が
広く知られている。このr Bresenhamの線描
画アルゴリズム」については、図形処理情報センター出
版の雑誌rp r XEL」Nα11の101〜107
ページに記載されている。However, in the above method, calculations after the decimal point are difficult, so as an improved drawing method, r Bres
A method called enhara's line drawing algorithm j is widely known. Regarding this ``Bresenham's line drawing algorithm'', please refer to the magazine ``rpr
stated on the page.
上述の方法及びr Bresenhamの線描画アルゴ
リズム」においては、いずれも、線を描画するのに1点
ずつ計算しなければならず、このため、描画時間が膨大
になってしまうという問題点があった。Both the above-mentioned method and Bresenham's line drawing algorithm had the problem that calculations had to be made for each point in order to draw a line, which resulted in an enormous amount of drawing time. .
これは、例えばマイクロプロセッサでFti画点を計算
して、画像メモリ(ビットマツプメモリ)に書き込む場
合、マイクロプロセッサが所定のデータビット幅(例え
ば8ビツトコンピユータでは8ビツト、本明細書では「
ワード幅」と呼ぶ。)毎にデータの書き込み及び読み出
しを行なうにもかかわらず、描画点の計算はlビット毎
に行われるため、その効率が極めて悪くなっていたから
である。特に、ドツトパターン形成面のX軸又はY軸に
対する傾きが小さい直線では、1つのワード幅内に多数
のドツトを発生させる必要があるため、その効率が著し
く悪くなっていた。This means that, for example, when a microprocessor calculates Fti pixels and writes them to an image memory (bitmap memory), the microprocessor calculates a predetermined data bit width (for example, 8 bits on an 8-bit computer;
This is called the word width. ) Although data is written and read every 1 bit, the calculation of the drawing point is performed every 1 bits, resulting in extremely low efficiency. In particular, in the case of a straight line where the inclination of the dot pattern formation surface with respect to the X-axis or Y-axis is small, it is necessary to generate a large number of dots within one word width, resulting in a significantly poor efficiency.
そこで本発明の課題は、描画速度を向上させた直線描画
方法及び装置を提供することである。Therefore, an object of the present invention is to provide a straight line drawing method and apparatus that improve drawing speed.
(課題を解決するための手段)
本発明は、ドツトパターン形成面のX軸とY軸のうち、
形成すべき直線との間の傾きが小さい方の軸と平行にス
キャンラインを設定すれば、同一のスキャンライン上に
発生させるべきドツトの数nは基本的にNとN+1 (
NとN−1と考えてもよい。)の2種類しか存在しない
という事実に基づいてなされたものである。(Means for Solving the Problems) The present invention provides that, among the X-axis and Y-axis of the dot pattern forming surface,
If the scan line is set parallel to the axis with the smaller inclination to the straight line to be formed, the number n of dots to be generated on the same scan line is basically N and N+1 (
You can think of them as N and N-1. This was done based on the fact that there are only two types:
第4図及び第5図を用いてこの事実を説明する。This fact will be explained using FIGS. 4 and 5.
第4図は傾き3/I Oの直線を表現するためのドツト
パターンを示したものであり、始点a及び終点すの近傍
部分を除いて同一水平スキャンライン上に発生させるド
ツトの数は3又は4である。また第5図は傾き7/30
の直線のドツトパターンであり、同一水平スキャンライ
ン上に発生させるドツトの数は4又は5である。このよ
うに、直線描画時に同一スキャンライン上に発生させる
ドツトの数は、小さい方の数をNとすれば、その始点及
び終点近傍部分を除き、NとN+1 (大きい方の数を
Nとすれば、NとN−1)の2種類しか存在しない。Figure 4 shows a dot pattern for expressing a straight line with a slope of 3/IO, and the number of dots generated on the same horizontal scan line is 3 or 3, except for the areas near the starting point a and the ending point A. It is 4. Also, in Figure 5, the slope is 7/30.
This is a straight line dot pattern, and the number of dots generated on the same horizontal scan line is 4 or 5. In this way, the number of dots generated on the same scan line when drawing a straight line is N and N + 1 (where the smaller number is N), excluding the areas near the start and end points (where the larger number is N). For example, there are only two types: N and N-1).
そこで本発明の直線描画方法においては、第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 the matrix of dot generation points constituting the dot pattern forming surface are sequentially shifted in a direction perpendicular to the scan lines. Then, a predetermined straight line pattern is formed on the dot pattern forming surface, and at this time, the basic number of dots to be generated on one scan line is determined based on the slope of the ideal straight line to be formed with respect to the scan line. N is calculated, the error between the position of the generated dot and the ideal straight line is accumulated for each shift of the scan line, and from the cumulative result, the number n of dots to be generated on the next scan line can be calculated as follows. It is determined whether it is N or N+1 or the above-mentioned N or N-1, and a number of dots according to the result of this determination are provided corresponding to a predetermined word width. The data is generated in a buffer register 104, and the contents of this buffer register 104 are transferred to a bitmap memory 106 provided corresponding to the matrix of the dot generation points.
このとき、理想直線の傾きΔy/Δxの逆数の整数部を
基本のドツト数Nとするのが好ましい。At this time, it is preferable to set the basic number N of dots to be the integer part of the reciprocal of the slope Δy/Δx of the ideal straight line.
そして上記方法に使用する本発明の直線描画装置は、
ドツト発生点のマトリックスに対応したビットマツプを
有し、且つ、所定のワード幅単位で書き込み及び読み出
しが行われるビットマツプメモリ106と、
前記ドツト発生点のマトリックスの一辺に平行なスキャ
ンラインを、そのスキャンラインに垂直な方向にシフト
させるスキャンラインシフト手段107と、
形成すべき理想直線の前記スキャンラインに対する傾き
に基づいて、1つのスキャンライン上に発生させる基本
のドツト数Nを求める基本ドツト数計算手段101と、
発生させたドツトの位置と前記理想直線との間の誤差を
前記スキャンラインのシフト毎に累積し、その累積結果
から、次のスキャンライン上に発生させるべきドツトの
数nが前記NとN+1とのいずれであるか、又は、前記
NとN−1とのいずれであるかを判定するドツト数判定
手段102と、ビットマツプメモリ106の前記ワード
幅に対応して設けられたバッファレジスタ104と、ド
ツト数判定手段102による判定結果に応じた数のドツ
トをバッファレジスタ104に発生させるドツト発生手
段103と、
バッファレジスタ104の内容をビ・ントマ・ンプメモ
リ106に転送する転送手段105とを有している。The linear drawing device of the present invention used in the above method includes: a bitmap memory 106 which has a bitmap corresponding to a matrix of dot generation points and is written and read in units of a predetermined word width; scan line shifting means 107 for shifting a scan line parallel to one side of the matrix of points in a direction perpendicular to the scan line; A basic dot number calculation means 101 that calculates the basic number N of dots to be generated; and an error between the position of the generated dots and the ideal straight line is accumulated for each shift of the scan line, and from the cumulative result, the following calculation is performed. A dot number determining means 102 for determining whether the number n of dots to be generated on a scan line is between N and N+1, or between N and N-1, and a bitmap memory. A buffer register 104 provided corresponding to the word width of 106, a dot generating means 103 for generating a number of dots in the buffer register 104 according to the determination result by the dot number determining means 102, and It has a transfer means 105 for transferring data to a virtual machine memory 106.
なお、基本ドツト数計算手段lO1は、理想直線の傾き
Δy/Δxの逆数の整数部を基本のドツト数Nとするも
のであるのが好ましい。It is preferable that the basic dot number calculating means lO1 is such that the basic dot number N is the integer part of the reciprocal of the slope Δy/Δx of the ideal straight line.
本発明においては、まず、形成すべき理想直線の傾きか
ら、同一スキャンライン上に発生させるべきドツトの数
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 determined from the slope of the ideal straight line to be formed, and each time the scan line is shifted,
The errors between the positions of the dots that have already been generated and the ideal straight line to be formed are accumulated, and from the cumulative result, the number n of dots to be generated on the next scan line is determined by the number n of dots to be generated on the next scan line.
1, or between N and N-1.
従って、その判定結果に基づいて、1つのスキャンライ
ン上に複数個のドツトを同時に発生させることができる
ようになり、このため、所定のワード幅単位で行われる
ビットマツプメモリ106への書き込みを効率よく行う
ことができて、描画速度が向上する。Therefore, it is possible to generate a plurality of dots simultaneously on one scan line based on the determination result, which makes writing to the bitmap memory 106 performed in units of a predetermined word width more efficient. It works well and improves drawing speed.
以下、本発明を実施例につき図面を参照して説明する。 DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will be described below with reference to embodiments and drawings.
第2図は本発明の一実施例による直線描画装置の構成を
示すブロック図である。FIG. 2 is a block diagram showing the configuration of a straight line drawing device according to an embodiment of the present invention.
この直線描画装置は、中央処理装置(CPU)11マイ
クロプログラムが格納されたROM2、ビットマツプメ
モリ3、このビットマツプメモリ30ビツトマツプに対
応する例えば第4図に示すドツトパターン形成面のY軸
方向の位置を決定するためのカウンタ4、上記ドツトパ
ターン形成面のX軸方向の位置を計算するためのX座標
位置決定用アキュムレータ(X−ACC)5、データバ
ス6、及び、ブロック等の出力装置7との間のインター
フェース(Ilo)8を有している。モしてCPUIは
演算部(ALU)11と、バッファレジスタの機能を具
備するドツト発生用のアキュムレータ(ACC)12と
を有している。This linear drawing device includes a central processing unit (CPU) 11, a ROM 2 in which a microprogram is stored, a bitmap memory 3, and a dot pattern forming surface corresponding to the bitmap, for example, in the Y-axis direction as shown in FIG. A counter 4 for determining the position, an accumulator for X-coordinate position determination (X-ACC) 5 for calculating the position of the dot pattern forming surface in the X-axis direction, a data bus 6, and an output device 7 such as a block. It has an interface (Ilo) 8 between it. Specifically, the CPU includes an arithmetic unit (ALU) 11 and an accumulator (ACC) 12 for dot generation, which has the function of a buffer register.
以下の説明では、第4図及び第5図に示すような横(X
軸方向)32ドツト、縦(Y軸方向)16ドットのドツ
トパターン形成面に直線描画を行うものとする。そして
本実施例の場合、ビットマツプメモリ3は8ビツトづつ
アクセスされるため、第4図及び第5図に示すように、
32X16ドツトのドツトパターン形成面はX軸方向に
4つに分割され、A列、B列、0列、D列の順に”oo
。In the following explanation, the horizontal (X
A straight line is drawn on a dot pattern forming surface of 32 dots (in the axial direction) and 16 dots in the vertical direction (Y-axis direction). In the case of this embodiment, since the bitmap memory 3 is accessed 8 bits at a time, as shown in FIGS. 4 and 5,
The dot pattern formation surface of 32 x 16 dots is divided into four in the X-axis direction, with rows A, B, 0, and D arranged in the order of "oo".
.
O11から“003F”までの64個のアドレスがビッ
トマツプメモリ3内に割り当てられている(第6図参照
)。そして第4図の例では、始点(0,0)から終点(
30,9)に直線を招いており、第5図の例では、始点
(0,O)から終点(30,7)に直線を描いている。Sixty-four addresses from O11 to "003F" are allocated in the bitmap memory 3 (see FIG. 6). In the example in Figure 4, from the starting point (0,0) to the ending point (
In the example shown in FIG. 5, a straight line is drawn from the starting point (0, O) to the ending point (30, 7).
次に、本実施例の直線描画方法を、CPUIの動作を示
す第3図のフローチャートに従って説明する。Next, the straight line drawing method of this embodiment will be explained with reference to the flowchart of FIG. 3 showing the operation of the CPUI.
まず演算部11により、描画すべき直線の傾きΔy/Δ
xから基本ドツト数Nが計算される。本実施例において
は、この基本ドツト数Nは次式から求められる。First, the calculation unit 11 calculates the slope of the straight line to be drawn by Δy/Δ
The basic number N of dots is calculated from x. In this embodiment, this basic number N of dots is obtained from the following equation.
N=INT(ΔX/Δy) −・−(1)即
ち、直線の傾きΔy/Δxの逆数の整数部が基本ドツト
数Nになる。第4図の例では、直線の1嘆きが371O
であるのでNは3となる。また第5図の例では傾きが7
730であるのでNは4となる。N=INT(ΔX/Δy) −·−(1) That is, the integer part of the reciprocal of the slope of the straight line Δy/Δx becomes the basic number N of dots. In the example shown in Figure 4, 1 point of the straight line is 371O
Therefore, N is 3. Also, in the example in Figure 5, the slope is 7.
730, so N is 4.
次に、直線の始点部分の描画、即ち最初のスキャンライ
ン上でのドツト発生を行う。本実施例においては、スキ
ャンラインをドツトパターン形成面のX軸と平行に設定
しており、第4図及び第5図の例では、いずれも始点a
が(0,O)であるので、ドツト発生を行う最初のスキ
ャンラインはy−0のスキャンラインである。この始点
描画及び後の終点描画は、直線の始点近傍部分及び終点
近傍部分では、同一スキャンライン上に発生させるべき
ドツトの数nは上記基本ドツト数NとN+1とのいずれ
かであるという基本法則が成り立たないために、別に行
う必要がある。Next, the starting point of the straight line is drawn, that is, dots are generated on the first scan line. In this example, the scan line is set parallel to the X axis of the dot pattern forming surface, and in the examples shown in FIGS. 4 and 5, the starting point a
is (0, O), the first scan line for dot generation is the y-0 scan line. This start point drawing and later end point drawing are based on the basic law that in the vicinity of the start point and the vicinity of the end point of a straight line, the number n of dots to be generated on the same scan line is either the basic dot number N or N+1 described above. does not hold, so it is necessary to do it separately.
この最初のスキャンライン上へのドツト発生は、WI画
すべき理想直線2のy座標が次のスキャンラインの方に
近くなるまで、即ち、第4図及び第5図の例では7−0
.5を越えるまで行わなければならない、その個数nは
、Δχ/2Δyが割り切れない場合、
n=INT(Δx / 2Δy) +1−(2)Δχ/
2Δyが割り切れる場合、
n−Δx / 2Δy ・−(2)’とな
る。第4図の例ではn=2、第5図の例ではn=3であ
る。Dots are generated on this first scan line until the y-coordinate of the ideal straight line 2 to be WI drawn is closer to the next scan line, that is, 7-0 in the example of FIGS. 4 and 5.
.. If Δχ/2Δy is not divisible, the number n that must be repeated until the number exceeds 5 is: n=INT(Δx/2Δy) +1−(2)Δχ/
If 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.
そこで、例えば第4図の例では、(0,0)と(1,0
)の点にドツトを発生させるために、第2図のドツト発
生用アキュムレータ(ACC)12にコード“1100
0000”を発生させ、これを、ビットマツプメモリ3
の直線の始点が存在するアドレス”oooo”に転送す
る(第6図参照)、このドツト発生用アキュムレータ(
ACC)12に発生させるコードのLSBが“°0”に
なった時点で、そのスキャンライン上でのドツト発生が
終了したことになるので、第2図のカウンタ4によりy
=3’+1として、スキャンラインを1シフトさせ、次
のスキャンライン上でのドツト発生を行う。Therefore, for example, in the example shown in Figure 4, (0,0) and (1,0
), a code "1100" is applied to the dot generation accumulator (ACC) 12 in FIG.
0000” and stores it in bitmap memory 3.
This dot generation accumulator (see Figure 6) is transferred to the address "oooo" where the starting point of the straight line exists (
When the LSB of the code generated in ACC) 12 reaches "°0", it means that the dot generation on that scan line has finished, so the counter 4 in Fig. 2
=3'+1, the scan line is shifted by one, and dots are generated on the next scan line.
y−1以降のスキャンライン上でのドツト発生を行うた
めには、そのスキャンライン上に発生させるべきドツト
の数nが基本ドツト数NとN+1とのいずれであるかを
決定しなければならない。In order to generate dots on scan lines after y-1, it is necessary to determine whether the number n of dots to be generated on that scan line is the basic number N or N+1.
基本ドツト数Nを上記(1)式のように定義した場合、
発生させたドツト位置と理想直線lとの間の誤差として
累積されるのはΔX/Δyの小数部である。そこで、演
算部11では、スキャンラインをl変化させる毎にこの
ΔX/Δyの小数部を加算していき、その値が1.0を
越えるまではn=Nとし、1.0を越えた時点でn=N
+ 1とする。When the basic number N of dots is defined as in equation (1) above,
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 calculation unit 11 adds the decimal part of ΔX/Δy every time the scan line is changed by l, and sets n=N until the value exceeds 1.0, and when it exceeds 1.0, So n=N
+1.
具体的には、y=0.5のときの、
の値を判定変数Eの初期値として用い、また、理想直線
iとの間の誤差を、
C−C,−<ΔX/Δy ) −N −・−(4)
として、スキャンラインを1変化させる毎に上記判定変
数已に誤差G、を加算していく。そして、この判定変数
Eが1を越えるまでは、そのスキャンライン上に発生さ
せるドツト数nとして基本ドツト数Nを出力し、Eが1
を越えた時点でn=N+1とする。Specifically, when y=0.5, the value of is used as the initial value of the judgment variable E, and the error from the ideal straight line i is calculated as CC, -<ΔX/Δy) -N −・−(4)
, the error G is added to the above judgment variable every time the scan line is changed by one. Then, until this judgment variable E exceeds 1, the basic number N of dots is output as the number n of dots to be generated on that scan line, and E becomes 1.
When it exceeds n=N+1.
E>1となった後は、誤差Gを、
G1G!−(ΔX/Δy)−N−1・・−(5)とし、
スキャンラインを1変化させる毎に判定変数已に今度は
誤差Gtを加算していく。そして、E>1の間はそのス
キャンライン上に発生させるドツト数nとしてN+1を
出力し、Eが1よりも小さくなった時点で誤差GをG+
に戻す。After E>1, the error G is G1G! -(ΔX/Δy)-N-1...-(5),
Every time the scan line is changed by one, the error Gt is added to the determination variable. Then, while E>1, N+1 is output as the number n of dots to be generated on the scan line, and when E becomes smaller than 1, the error G is set to G+
Return to
即ち、判定変数Eが1よりも小さい間は、その判定変数
Eが1を越えるまで、スキャンラインを1変化させるご
とに判定変数已に誤差としてGを加算するとともに、そ
のスキャンライン上に発生させるべきドツトの数nをN
と判定し続け、−方、判定変数Eが1よりも大きい間は
、その判定変数Eが1を下回るまで、スキャンラインを
l変化させるごとに判定変数Eに誤差としてG2を加算
するとともに、そのスキャンライン上に発生させるべき
ドツトの数nをN+1と判定し続ける。That is, while the judgment variable E is smaller than 1, G is added as an error to the judgment variable every time the scan line changes by 1 until the judgment variable E exceeds 1, and G is generated on the scan line. Let the number n of power dots be N
On the other hand, while the judgment variable E is larger than 1, G2 is added as an error to the judgment variable E every time the scan line changes l until the judgment variable E becomes less than 1. The number n of dots to be generated on the scan line continues to be determined as N+1.
この方法に従えば、第4図の例において、y=1のスキ
ャンライン上に発生させるドツト数は基本ドツト数3で
あるので、第2図のドツト発生用アキュムレータ(AC
C)12にコード“0O111000”を発生させ、こ
れを、ビットマツプメモリ3のアドレス″0004 ”
に転送する(第6図参照)。このとき、ドツト発生用ア
キュムレータ(ACC)12に発生させるコードにおい
て、“1″の立ち上がるビット位f(y−1のスキャン
ライン上では左から3ビツト目〉は、X軸方向における
発生ドツト数を累積して、その位置を計算するためのX
座標位置決定用アキュムレータ(X−ACC)5を用い
て決定される。即ち、このX座標位置決定用アキュムレ
ータ(X−ACC)5において、既に発生させたドツト
の数を累積し、その累積値をワード幅(本実施例の場合
には8)で割った剰余Rの次のビット位置を、ドツト発
生用アキュムレータ(ACC)12における“′1“の
立ち上がるビット位置としてCPU1により決定する。According to this method, in the example of FIG. 4, the basic number of dots generated on the scan line of y=1 is 3, so the dot generation accumulator (AC
C) Generate code "0O111000" in bitmap memory 3 and write it to address "0004" of bitmap memory 3.
(See Figure 6). At this time, in the code generated by the dot generation accumulator (ACC) 12, the bit position f (3rd bit from the left on the y-1 scan line) at which "1" rises indicates the number of generated dots in the X-axis direction. X to accumulate and calculate its position
The coordinate position is determined using an accumulator (X-ACC) 5. That is, in this X-coordinate position determination accumulator (X-ACC) 5, the number of dots that have already been generated is accumulated, and the accumulated value is divided by the word width (8 in the case of this embodiment), and the remainder R is calculated. The next bit position is determined by the CPU 1 as the bit position at which "'1" in the dot generation accumulator (ACC) 12 rises.
既述したy=oのスキャンラインの場合と同様、このy
−iのスキャンラインにおいても、ドツト発生用アキュ
ムレータ(ACC)12に発生させるコードのLSBが
Onになった時点で、このスキャンライン上でのドツト
発生が終了したことになるので、第2図のカウンタ4に
より)’=)’+1として、スキャンラインをシフトさ
せ、次に、y−2のスキャンライン上でのドツト発生を
行う。As in the case of the scan line of y=o described above, this y
-i scan line as well, dot generation on this scan line ends when the LSB of the code generated in the dot generation accumulator (ACC) 12 turns on, so as shown in FIG. The counter 4 sets )'=)'+1 to shift the scan line, and then generates a dot on the y-2 scan line.
スキャンラインが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のアドレス“ooos”に転送する。そして、その
時点で、直線の描画位置がX軸方向に移動してB列の領
域に入ったと判断し、残りの1ビツトのみを“1゛°と
したコード“10000000″をドツト発生用アキュ
ムレータ(ACC)12に発生させ、これを、ビットマ
ツプメモリ3のアドレス″0009”に転送する。Since the determination variable E exceeds 1 when the scan line moves to y=2, the number of dots to be generated on the scan line at y=2 is 3+1=4. Therefore, "1" was set to 4 in the dot generation accumulator (ACC) 12.
In this case, "°1" determined by the X-coordinate position determining accumulator (X-ACC) 5
Since the rising bit position is the 3rd bit from the LSB, it is not possible to set up 4 "1 degrees". Therefore, the dot generation accumulator (ACC) 12 is
A code ``00000111'' consisting of ``1'' is generated and transferred to the address ``ooos'' of the bitmap memory 3, as shown in FIG. It is determined that the dot has moved in the X-axis direction and entered the area of column B, and the code "10000000" with only the remaining 1 bit set to "1°" is generated in the dot generation accumulator (ACC) 12, and this is Transfer to address "0009" of map memory 3.
そして、ここでドツト発生用アキエムレータ(ACC)
12に発生させたコードのLSBがO”°となるので、
このスキャンライン上での直線描画が終了したと判断し
、次のスキャンライン上での直線描画に移る。この時、
判定変数Eに加算する誤差はG2になっている。And here, the achi emulator (ACC) for dot generation
Since the LSB of the code generated in 12 is O”°,
It is determined that straight line drawing on this scan line has been completed, and the process moves on to straight line drawing on the next scan line. At this time,
The error added to the determination variable E is G2.
スキャンラインがy=3に移動した時には、判定変数E
が1を下回るので、発生ドツト数nは基本ドツト数3と
なる。そして、上記と同様にして所定位置にドツトを発
生させた後、更にスキャンラインを移動させる。この時
、判定変数Eに加算する誤差はGtになっている。When the scan line moves to y=3, the judgment variable E
is less than 1, the number n of generated dots is the basic number 3 of dots. Then, after generating dots at predetermined positions in the same manner as above, the scan line is further moved. At this time, the error added to the determination variable E is Gt.
以下同様にして、ビットマツプメモリ3のアドレス“0
026“までドツトを発生させ、終点描画ステップに入
る。Similarly, address “0” of bitmap memory 3 is
Dots are generated up to 026" and the end point drawing step is started.
この終点描画ステップは、発生させるドツト位置が終点
座標に達したかどうかを判断し、達している場合には、
そのスキャンライン上に発生させるべきドツト数nの如
何にかかわらず、ドツト発生位置を終点座標位置でクリ
ップすることにより行うことができる。This end point drawing step determines whether the generated dot position has reached the end point coordinates, and if it has reached the end point coordinates,
Regardless of the number n of dots to be generated on the scan line, this can be done by clipping the dot generation position at the end point coordinate position.
以上の動作により、例えば第4図に示すようなドツトパ
ターン形成面に直線を描画するためのドツトパターンが
ビットマツプメモリ3内に格納される。Through the above operations, a dot pattern for drawing a straight line on the dot pattern forming surface as shown in FIG. 4, for example, is stored in the bitmap memory 3.
上述したように、本実施例においては、バッファレジス
タとしての機能を具備するドツト発生用アキュムレータ
(ACC)12のワード幅単位で一度にドツトを発生さ
せることができるので、CPU1の演算部(ALU)1
1での計算効率が良くなり、描画速度が向上する。As described above, in this embodiment, dots can be generated at once in word width units of the dot generation accumulator (ACC) 12, which functions as a buffer register, so that the arithmetic unit (ALU) of the CPU 1 1
1 improves calculation efficiency and improves drawing speed.
なお、上述の実施例では、ドツトパターン形成面のX軸
に対する傾斜角度dがO’<d<45゜の直線を描画す
る場合を説明したが、それ以外の直線の場合にも、はぼ
同様の構成によって描画することができる。その場合に
は、第1図の基本ドツト数計算手段101の前段に、描
画すべき直線の傾きを識別するための傾き識別手段と、
この傾き識別手段により識別された直線の傾きに応じて
適当に座標変換を行うための座標変換手段を設ければよ
い。例えば、描画すべき直線の傾斜角度dが45°<d
<90°の場合には、座標変換手段によりx=y、y=
xの座標変換を行った後、上述の実施例と同じ手順でド
ツト発生及びビットマツプメモリへの書き込みを行い、
このビットマツプメモリから読み出して出力する際に、
再び座標変換手段によりx=y、y””xの座標変換を
行って、座標系を元に戻せばよい。或いは、ビットマツ
プメモリへの書き込みを行う際に、座標系を元に戻して
もよい。同様に、−45” <d<Ooの場合には、y
=−yの座標変換を行えばよく、また、−90@<d<
−45@の場合には、χ=−y、y−xの座標変換を行
えばよい。In addition, in the above-mentioned embodiment, the case where a straight line is drawn where the inclination angle d of the dot pattern formation surface with respect to the It can be drawn by the configuration of . In that case, a slope identifying means for identifying the slope of the straight line to be drawn is provided before the basic dot number calculation means 101 shown in FIG.
It is sufficient to provide a coordinate conversion means for appropriately converting the coordinates according to the slope of the straight line identified by the slope recognition means. For example, if the inclination angle d of the straight line to be drawn is 45°<d
In the case of <90°, x=y, y=
After performing coordinate transformation of x, dot generation and writing to bitmap memory are performed in the same procedure as in the above embodiment.
When reading and outputting from this bitmap memory,
The coordinate transformation means may perform the coordinate transformation of x=y, y""x again to restore the coordinate system to its original state. Alternatively, the coordinate system may be restored to its original state when writing to the bitmap memory. Similarly, if −45”<d<Oo, then y
=-y coordinate transformation, and -90@<d<
In the case of -45@, it is sufficient to perform coordinate transformation of χ=-y, y-x.
なお、上記実施例の方法では、d=0@及びd=90@
の直線は描画することができない(基本ドツト数Nの計
算ができないため)が、その場合でも、上述した直線の
傾き識別手段を用いれば、その直線を描画することがで
きる。例えば、傾き識別手段により直線の傾きがd=0
°又はd=90°であることを識別したならば、その直
線の任意の点のX座標又はX座標を求め、その座標に基
づいて、X軸又はY軸に平行な特定のスキャンライン上
の始点及び終点間の全てのドツト発生点にドツトを発生
させればよい。In addition, in the method of the above embodiment, d=0@ and d=90@
Although the straight line cannot be drawn (because the basic number N of dots cannot be calculated), even in that case, the straight line can be drawn by using the above-mentioned straight line slope identification means. For example, the slope of a straight line is determined by the slope identification means to be d=0.
Once you have identified that d = 90°, find the X coordinate or X coordinate of any point on that straight line, and based on that coordinate, It is sufficient to generate dots at all dot generation points between the starting point and the ending point.
本発明の方法及び装置は、あらゆる種類のドツト式プロ
ッタ、プリンタ、デイスプレィ等に適用が可能である。The method and apparatus of the present invention can be applied to all types of dot plotters, printers, displays, etc.
その場合、ドツトパターン形成面は実際に存在している
必要はなく、ビットマツプメモリ内に展開された仮想的
な概念であってよい。In that case, the dot pattern forming surface does not need to actually exist, but may be a virtual concept developed in a bitmap memory.
また、液晶デイスプレィ等のデイスプレィ装置に本発明
を適用する場合には、そのデイスプレィ装置の各画素を
1つのドツトとみなして、本発明を適用すればよい。Further, when the present invention is applied to a display device such as a liquid crystal display, each pixel of the display device can be regarded as one dot and the present invention can be applied.
本発明の方法及び装置によれば、直線の描画処理速度を
、従来のものよりも速くすることができる。特に、従来
処理速度が極めて遅かった一方の軸に対して傾きの小さ
い直線はど、その効果は顕著である。According to the method and apparatus of the present invention, the processing speed for drawing straight lines can be made faster than in the conventional method. This effect is particularly noticeable for straight lines that have a small slope with respect to one axis, for which the processing speed has conventionally been extremely slow.
第1図は本発明の基本構成を示すブロック図、第2図は
本発明の一実施例による直線描画装置の構成を示すブロ
ック図、第3図は第2図のCPUの動作を示すフローチ
ャート、第4図及び第5図は直線描画の実例を示す概念
図、第6図はビットマツプメモリの内容を示す説明図、
第7図は従来の直線描画方法を示す説明図である。
なお、図面に用いた符号において、
1 ・・・・・・ CPU
3 ・・・・・・ ビットマツプメモリot
02
03
04
05
06
07
カウンタ
X座標位置決定用アキュムレータ
(X−ACC)
演算部(ALU)
ドツト発生用アキュムレータ
(ACC)
基本ドツト数計算手段
ドツト数判定手段
ドツト発生手段
バッファレジスタ
転送手段
ビットマツプメモリ
スキャンラインシフト手段FIG. 1 is a block diagram showing the basic configuration of the present invention, FIG. 2 is a block diagram showing the configuration of a linear drawing device according to an embodiment of the present invention, and FIG. 3 is a flowchart showing the operation of the CPU in FIG. 4 and 5 are conceptual diagrams showing an example of straight line drawing, and FIG. 6 is an explanatory diagram showing the contents of the bitmap memory.
FIG. 7 is an explanatory diagram showing a conventional straight line drawing method. In addition, in the symbols used in the drawings, 1 ... CPU 3 ... Bit map memory ot 02 03 04 05 06 07 Counter X-coordinate position determination accumulator (X-ACC) Arithmetic unit (ALU ) Dot generation accumulator (ACC) Basic dot number calculation means Dot number judgment means Dot generation means Buffer register transfer means Bit map memory scan line shift means
Claims (4)
トパターン形成面にドットによる直線パターンを形成さ
せる直線描画方法において、 前記ドット発生点のマトリックスの一辺に平行なスキャ
ンラインを、そのスキャンラインに垂直な方向に順次シ
フトさせて前記直線パターンを形成させるようになし、 その際、形成すべき理想直線の前記スキャンラインに対
する傾きに基づいて、1つのスキャンライン上に発生さ
せる基本のドット数Nを求め、発生させたドットの位置
と前記理想直線との間の誤差を前記スキャンラインのシ
フト毎に累積し、その累積結果から、次のスキャンライ
ン上に発生させるべきドットの数nが前記NとN+1と
のいずれであるか、又は、前記NとN−1とのいずれで
あるかを判定し、 この判定結果に応じた数のドットを、所定のワード幅に
対応して設けられたバッファレジスタに発生させ、 このバッファレジスタの内容を、前記ドット発生点のマ
トリックスに対応して設けられたビットマップメモリに
転送することを特徴とする直線描画方法。(1) In a linear drawing method in which a straight line pattern of dots is formed on a dot pattern forming surface where dot generation points are arranged in a matrix, a scan line parallel to one side of the matrix of dot generation points is drawn perpendicular to the scan line. The linear pattern is formed by sequentially shifting the line pattern in the following directions, and at this time, the basic number N of dots to be generated on one scan line is determined based on the slope of the ideal straight line to be formed with respect to the scan line. , the error between the position of the generated dot and the ideal straight line is accumulated for each shift of the scan line, and from the cumulative result, the number n of dots to be generated on the next scan line is determined by the above N and N+1. or N or N-1, and the number of dots according to the result of this judgment is placed in a buffer register provided corresponding to a predetermined word width. A straight line drawing method characterized in that the contents of the buffer register are transferred to a bitmap memory provided corresponding to the matrix of dot generation points.
前記基本のドット数Nとすることを特徴とする請求項1
記載の直線描画方法。(2) Claim 1 characterized in that the integer part of the reciprocal of the slope Δy/Δx of the ideal straight line is the basic number N of dots.
The straight line drawing method described.
ップを有し、且つ、所定のワード幅単位で書き込み及び
読み出しが行われるビットマップメモリと、 前記ドット発生点のマトリックスの一辺に平行なスキャ
ンラインを、そのスキャンラインに垂直な方向にシフト
させるスキャンラインシフト手段と、 形成すべき理想直線の前記スキャンラインに対する傾き
に基づいて、1つのスキャンライン上に発生させる基本
のドット数Nを求める基本ドット数計算手段と、 発生させたドットの位置と前記理想直線との間の誤差を
前記スキャンラインのシフト毎に累積し、その累積結果
から、次のスキャンライン上に発生させるべきドットの
数nが前記NとN+1とのいずれであるか、又は、前記
NとN−1とのいずれであるかを判定するドット数判定
手段と、 前記ビットマップメモリの前記ワード幅に対応して設け
られたバッファレジスタと、 前記ドット数判定手段による判定結果に応じた数のドッ
トを前記バッファレジスタに発生させるドット発生手段
と、 前記バッファレジスタの内容を前記ビットマップメモリ
に転送する転送手段とを有することを特徴とする直線描
画装置。(3) A bitmap memory that has a bitmap corresponding to a matrix of dot generation points and that is written and read in units of a predetermined word width, and a scan line parallel to one side of the matrix of dot generation points. , a scan line shift means for shifting in a direction perpendicular to the scan line, and a basic dot number for determining the basic number N of dots to be generated on one scan line based on the slope of the ideal straight line to be formed with respect to the scan line. calculating means; accumulating the error between the position of the generated dot and the ideal straight line for each shift of the scan line; and from the cumulative result, calculating the number n of dots to be generated on the next scan line; dot number determining means for determining whether the number is N or N+1, or whether the number is N or N-1; and a buffer register provided corresponding to the word width of the bitmap memory. and dot generation means for generating a number of dots in the buffer register according to the determination result by the dot number determination means, and transfer means for transmitting the contents of the buffer register to the bitmap memory. A straight line drawing device.
きΔy/Δxの逆数の整数部を前記基本のドット数Nと
するものであることを特徴とする請求項3記載の直線描
画装置。(4) The straight line drawing device according to claim 3, wherein the basic dot number calculation means sets the basic dot number N to be the integer part of the reciprocal of the slope Δy/Δx of the ideal straight line.
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 true JPH03144867A (en) | 1991-06-20 |
JP2630843B2 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) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH09150558A (en) * | 1995-11-29 | 1997-06-10 | Nec Corp | Plotting device for printer |
JP2002342763A (en) * | 2001-05-15 | 2002-11-29 | Matsushita Electric Ind Co Ltd | Line segment plotting device |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS6292077A (en) * | 1985-10-18 | 1987-04-27 | Fujitsu Ltd | Pattern generation method |
-
1989
- 1989-10-31 JP JP1284001A patent/JP2630843B2/en not_active Expired - Fee Related
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPS6292077A (en) * | 1985-10-18 | 1987-04-27 | Fujitsu Ltd | Pattern generation method |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH09150558A (en) * | 1995-11-29 | 1997-06-10 | Nec Corp | Plotting device for printer |
JP2002342763A (en) * | 2001-05-15 | 2002-11-29 | Matsushita Electric Ind Co Ltd | Line segment plotting device |
JP4596678B2 (en) * | 2001-05-15 | 2010-12-08 | パナソニック株式会社 | Line drawing device |
Also Published As
Publication number | Publication date |
---|---|
JP2630843B2 (en) | 1997-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8698808B2 (en) | Conversion of dashed strokes into quadratic Bèzier segment sequences | |
US5016001A (en) | Pattern data generating system | |
US10762392B2 (en) | Tiling format for convolutional neural networks | |
KR102188543B1 (en) | Graphic processing unit | |
JP2006221650A (en) | Method for unindexing geometric primitives, rasterization device, and computer-readable medium | |
US9928621B2 (en) | Line stylization through graphics processor unit (GPU) textures | |
US4972330A (en) | Clipping process and processor | |
KR940001880B1 (en) | Drawing method and apparatus | |
JP3037854B2 (en) | Character generation method and device | |
KR102606207B1 (en) | Tiling algorithm for matrix math instruction set | |
JPH03144867A (en) | Method and device for plotting straight line | |
EP0464794B1 (en) | Painting pattern generation system and pattern painting method using the system | |
JP2770582B2 (en) | Figure filling device | |
JP3034140B2 (en) | Character generation method and device | |
KR930000693B1 (en) | Pattern data generating apparatus | |
JPH0519194B2 (en) | ||
JP2605609B2 (en) | Dot display processing device | |
JPH11224331A (en) | Raster image generation device and raster image generation method | |
JP2001013954A (en) | Plotting device and method therefor, and recording medium | |
JPH0439782A (en) | Painting-out device for graphic | |
JPH04153786A (en) | Quadrilateral area filling device | |
JP2000242802A (en) | Graphic processor | |
JPS59180777A (en) | System for rotation processing of graphic data | |
JPH04331988A (en) | Stroke character generation device | |
JPH05127662A (en) | Display device of information equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
LAPS | Cancellation because of no payment of annual fees |