JPH04352290A - Straight line drawing device - Google Patents

Straight line drawing device

Info

Publication number
JPH04352290A
JPH04352290A JP12720591A JP12720591A JPH04352290A JP H04352290 A JPH04352290 A JP H04352290A JP 12720591 A JP12720591 A JP 12720591A JP 12720591 A JP12720591 A JP 12720591A JP H04352290 A JPH04352290 A JP H04352290A
Authority
JP
Japan
Prior art keywords
straight line
value
register
point
points
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.)
Pending
Application number
JP12720591A
Other languages
Japanese (ja)
Inventor
Shuichi Takada
周一 高田
Yuji Kamiyama
神山 祐史
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.)
Panasonic Holdings Corp
Original Assignee
Matsushita Electric Industrial Co Ltd
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 Matsushita Electric Industrial Co Ltd filed Critical Matsushita Electric Industrial Co Ltd
Priority to JP12720591A priority Critical patent/JPH04352290A/en
Publication of JPH04352290A publication Critical patent/JPH04352290A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To provide the straight line drawing device which draws a straight line at a high speed. CONSTITUTION:A drawing point quantity determination variable register 43 outputs a negative or nonnegative value at a specific period and specific frequency, a drawing point quantity determination variable and drawing point quantity control part 47 outputs the quotient (n) of the integral division of the numbers of (x)-axial and (y)-axis drawing points or a value n+1 according to the output value, and a horizontal line drawing part 51 draws a horizontal line of the number (n) or (n+1) of drawing points in each (y) coordinate value. Then the horizontal line is drawn at a time up to the coordinate point where the (x) coordinate and (y) coordinate vary at the same time, so the straight line is drawn at a high speed.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は、ビットマップディスプ
レイに画像の表示を行うグラフィックス表示システム等
に適用される直線描画装置に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a straight line drawing device applied to a graphics display system for displaying images on a bitmap display.

【0002】0002

【従来の技術】従来より、直線を描画するアルゴリズム
として、Bresenhamの線分アルゴリズムが知ら
れている。上記アルゴリズムは、例えば「コンピュータ
グラフィックス」,ジェー・ディー・フォーリー他著、
今宮淳美訳、日本コンピュータ協会出版(1984年)
、pp.443−446に記載されている。
2. Description of the Related Art Conventionally, Bresenham's line segment algorithm has been known as an algorithm for drawing straight lines. The above algorithm can be used, for example, in "Computer Graphics", by J.D. Foley et al.
Translated by Atsumi Imamiya, published by Japan Computer Association (1984)
, pp. 443-446.

【0003】以下、この種のアルゴリズムについて、図
4に示すフローチャートに基づき説明する。ここで、描
画する直線の始点座標を(x1,y1)、終点座標を(
x2,y2)とし、簡単のため、x1<x2、y1<y
2、かつ直線の傾きが0から1の間の値とする。なお、
始点から終点までのx軸方向、およびy軸方向の格子点
の数をそれぞれΔx、Δyとすると、Δx=x2−x1
+1、Δy=y2−y1+1である。
[0003] This type of algorithm will be explained below based on the flowchart shown in FIG. Here, the starting point coordinates of the straight line to be drawn are (x1, y1), and the ending point coordinates are (
x2, y2), and for simplicity, x1<x2, y1<y
2, and the slope of the straight line is a value between 0 and 1. In addition,
If the numbers of grid points in the x-axis direction and y-axis direction from the start point to the end point are Δx and Δy, respectively, Δx=x2−x1
+1, Δy=y2−y1+1.

【0004】まず、変数x、yの初期値としてx1、y
1を設定する。また、描画点決定変数dの初期値として
、d=Δy−Δxに設定する(S401)。次に、描画
点決定変数dの符号を判別し(S402)、負であれば
、この描画点決定変数dにΔyを加算する(S403)
一方、非負であれば、Δy−Δxを加算する(S404
)とともに変数yの値を1だけ増加させる(S405)
First, x1, y are the initial values of variables x, y.
Set 1. Furthermore, the initial value of the drawing point determination variable d is set to d=Δy−Δx (S401). Next, the sign of the drawing point determining variable d is determined (S402), and if it is negative, Δy is added to this drawing point determining variable d (S403).
On the other hand, if it is non-negative, Δy−Δx is added (S404
) and increase the value of the variable y by 1 (S405)
.

【0005】その後、座標(x,y)で示される1点を
描画し(S406)、変数xの値を1だけ増加させた後
(S407)、x>x2かどうか、すなわち、終点まで
描画されたかどうかを判定し(S408)、YESにな
るまで上記S402以降を繰り返す。上記のようなアル
ゴリズムを適用した直線描画装置としては、例えば図5
に示すような構成が考えられる。
[0005] After that, one point indicated by the coordinates (x, y) is drawn (S406), and the value of the variable x is increased by 1 (S407). The process from S402 onward is repeated until the result is YES (S408). An example of a straight line drawing device that applies the above algorithm is the one shown in Figure 5.
A configuration as shown in is possible.

【0006】図5において、10は描画点の座標を出力
する描画部である。11は値Δy−Δxを格納するレジ
スタである。12は値Δyを格納するレジスタである。 13は描画点決定変数dを格納する描画点決定変数レジ
スタで、初期値としては値Δy−Δxが格納される。
In FIG. 5, reference numeral 10 denotes a drawing section that outputs the coordinates of a drawing point. 11 is a register that stores the value Δy−Δx. 12 is a register that stores the value Δy. Reference numeral 13 denotes a drawing point determination variable register for storing a drawing point determination variable d, and the value Δy−Δx is stored as an initial value.

【0007】14はレジスタ11の内容と描画点決定変
数レジスタ13の内容とを加算する加算器である。15
はレジスタ12の内容と描画点決定変数レジスタ13の
内容とを加算する加算器である。16は後述する描画点
決定変数・座標変化量制御部17からの切り換え制御信
号に基づいて、加算器14・15の加算結果のうちの一
方を選択出力する選択器である。
Reference numeral 14 denotes an adder that adds the contents of the register 11 and the contents of the drawing point determination variable register 13. 15
is an adder that adds the contents of the register 12 and the contents of the drawing point determination variable register 13. A selector 16 selects and outputs one of the addition results of the adders 14 and 15 based on a switching control signal from a drawing point determination variable/coordinate change amount control unit 17, which will be described later.

【0008】17は描画点決定変数レジスタ13から出
力される描画点決定変数dの符号sに基づいて、上記選
択器16への切り換え制御信号、および前回の描画点か
ら次の描画点へのx座標およびy座標の変化量を求めて
出力する描画点決定変数・座標変化量制御部である。1
8・19はそれぞれ描画点のx、y座標を格納するレジ
スタで、初期値としては値x1、または値y1が格納さ
れる。
Reference numeral 17 indicates a switching control signal to the selector 16 based on the sign s of the drawing point determining variable d output from the drawing point determining variable register 13, and a switching control signal x from the previous drawing point to the next drawing point. This is a drawing point determination variable/coordinate change amount control unit that calculates and outputs the amount of change in coordinates and y coordinates. 1
Registers 8 and 19 respectively store the x and y coordinates of the drawing point, and the value x1 or the value y1 is stored as an initial value.

【0009】20はレジスタ18・19に格納されてい
るx、y座標に、描画点決定変数・座標変化量制御部1
7から出力される変化量を加算して描画点の座標を求め
、レジスタ18・19を更新するとともに上記描画点の
座標を出力するx、y座標算出部である。21はレジス
タ18に格納されている描画点の座標xが終点の座標x
2よりも大きくなったかどうかを調べて、直線の描画処
理が終了したかどうかを決定する終了判定部である。
Reference numeral 20 inputs the drawing point determination variable/coordinate change amount control unit 1 to the x and y coordinates stored in the registers 18 and 19.
This is an x, y coordinate calculation unit that adds the amount of change output from 7 to obtain the coordinates of the drawing point, updates the registers 18 and 19, and outputs the coordinates of the drawing point. 21 indicates that the coordinate x of the drawing point stored in the register 18 is the coordinate x of the end point.
This is an end determination unit that determines whether the straight line drawing process has ended or not by checking whether the straight line has become larger than 2 or not.

【0010】22は起動信号が入力されてから、終了判
定部21で描画の処理が終了したと判定されるまでの間
、上記描画部10の動作を制御する制御部である。この
ように構成することによって、制御部22の制御に基づ
いて、描画点決定変数・座標変化量制御部17および選
択器16が前記S402を実行し、加算器14・15が
それぞれS404、S403を実行し、x、y座標算出
部20がS405〜S407を実行し、終了判定部21
がS408を実行することにより、始点から終点までの
描画点のx、y座標がx、y座標算出部20から出力さ
れる。
Reference numeral 22 denotes a control section that controls the operation of the drawing section 10 from when the activation signal is input until the end judgment section 21 judges that the drawing process has ended. With this configuration, based on the control of the control unit 22, the drawing point determination variable/coordinate change amount control unit 17 and the selector 16 execute S402, and the adders 14 and 15 execute S404 and S403, respectively. The x, y coordinate calculation unit 20 executes S405 to S407, and the end determination unit 21
By executing S408, the x, y coordinates of the drawing point from the starting point to the ending point are output from the x, y coordinate calculation unit 20.

【0011】そこで、上記x、y座標の値に基づいて、
図示しない画像メモリをマッピングすることにより、始
点から終点までの直線の描画が行われる。
[0011] Therefore, based on the values of the above x and y coordinates,
By mapping an image memory (not shown), a straight line from the starting point to the ending point is drawn.

【0012】0012

【発明が解決しようとする課題】しかしながら、上記従
来の直線描画装置では、描画点の座標を1点ずつ求めて
描画するため、直線の描画に要する時間が長くかかると
いう問題点を有していた。特に上記問題点は、例えばG
UI(graphical user interfa
ce)と称されるインタラクティブな操作環境やCAD
(computer aided design )シ
ステム等の普及、およびグラフィックス表示システムの
高解像度化等に伴って、一層顕著なものとなりつつある
[Problems to be Solved by the Invention] However, the above-mentioned conventional line drawing device has the problem that it takes a long time to draw a straight line because the coordinates of the drawing points are determined one by one. . In particular, the above problem is, for example, G
UI (graphical user interface)
An interactive operating environment called ce) and CAD
With the spread of (computer aided design) systems and the increase in resolution of graphics display systems, this problem is becoming more prominent.

【0013】本発明は上記の点に鑑み、高速動作の可能
な演算素子等を用いなくても、直線の描画を高速に行い
得る直線描画装置の提供を目的としている。
In view of the above points, the present invention aims to provide a straight line drawing device that can draw straight lines at high speed without using arithmetic elements capable of high speed operation.

【0014】[0014]

【課題を解決するための手段】上記目的を達成するため
、本発明は、始点と終点とを結ぶ直線を描画する直線描
画装置において、第1の座標軸および第2の座標軸のう
ち、始点と終点間の座標軸方向の描画点数が小さい方の
座標軸における始点と終点間の各座標値ごとに、他方の
座標軸方向の所定の個数の描画点から成る部分直線を描
画する座標軸方向部分直線描画手段を備えたことを特徴
としている。
[Means for Solving the Problem] In order to achieve the above object, the present invention provides a straight line drawing device for drawing a straight line connecting a starting point and an ending point. A partial straight line drawing means in the coordinate axis direction is provided for drawing a partial straight line consisting of a predetermined number of drawing points in the direction of the other coordinate axis for each coordinate value between the starting point and the end point in the coordinate axis with the smaller number of drawing points in the direction of the other coordinate axis. It is characterized by

【0015】[0015]

【作用】上記の構成により、座標軸方向部分直線描画手
段は、第1の座標軸および第2の座標軸のうち、始点と
終点間の座標軸方向の描画点数が小さい方の座標軸にお
ける始点と終点間の各座標値ごとに、他方の座標軸方向
の所定の個数の描画点から成る部分直線を描画する。す
なわち、一方の座標値が同一の所定個数の描画点ごとに
、1回だけ描画処理が行われる。
[Operation] With the above configuration, the coordinate axis direction partial straight line drawing means can draw each straight line between the starting point and the ending point in the coordinate axis which has the smaller number of drawing points in the coordinate axis direction between the starting point and the ending point, of the first coordinate axis and the second coordinate axis. For each coordinate value, a partial straight line consisting of a predetermined number of drawing points in the direction of the other coordinate axis is drawn. That is, the drawing process is performed only once for each predetermined number of drawing points that have the same coordinate value on one side.

【0016】[0016]

【実施例】以下、本発明の一実施例を図1ないし図3に
基づいて説明する。ここで、描画する直線の始点座標を
(x1,y1)、終点座標を(x2,y2)とし、簡単
のため、x1<x2、y1<y2、かつ直線の傾きが0
から1の間の値とする。なお、始点から終点までのx軸
方向、およびy軸方向の格子点の数をそれぞれΔx、Δ
yとすると、Δx=x2−x1+1、Δy=y2−y1
+1である。また、描画する直線の幅をhとする。
DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described below with reference to FIGS. 1 to 3. Here, the starting point coordinates of the straight line to be drawn are (x1, y1), the ending point coordinates are (x2, y2), and for simplicity, x1 < x2, y1 < y2, and the slope of the straight line is 0.
and 1. Note that the number of grid points in the x-axis direction and y-axis direction from the start point to the end point are Δx and Δ
If y, Δx=x2-x1+1, Δy=y2-y1
+1. Further, the width of the straight line to be drawn is assumed to be h.

【0017】図1は直線描画装置の構成を示すブロック
図である。図1において、31は値Δx、Δyを入力し
、整数除算Δx/Δyの商n、値(n+1)・Δy−Δ
x、および値n・Δy−Δxを算出する初期値算出部で
ある。なお、上記商nは基本描画点数で、x軸方向に描
画される直線の描画点数は、後述するようにnまたはn
+1に設定される。
FIG. 1 is a block diagram showing the configuration of a straight line drawing device. In FIG. 1, 31 inputs the values Δx and Δy, the quotient n of integer division Δx/Δy, and the value (n+1)・Δy−Δ
This is an initial value calculation unit that calculates x and the value n·Δy−Δx. Note that the above quotient n is the basic number of drawing points, and the number of drawing points of a straight line drawn in the x-axis direction is n or n as described later.
Set to +1.

【0018】32は上記商nと直線幅hとに基づいて値
x1−(h−1)・n/2を算出し、出力する初期値補
正部である。なお、直線幅hが1の場合には、始点のx
座標x1がそのまま出力されることになる。40は描画
処理を行う描画部である。41は初期値算出部31から
出力される値n・Δy−Δxを格納するレジスタである
Reference numeral 32 denotes an initial value correction section that calculates the value x1-(h-1)·n/2 based on the above-mentioned quotient n and the straight line width h, and outputs the value x1-(h-1)·n/2. Note that if the straight line width h is 1, the starting point x
The coordinate x1 will be output as is. 40 is a drawing unit that performs drawing processing. 41 is a register that stores the value n·Δy−Δx output from the initial value calculation unit 31.

【0019】42は初期値算出部31から出力される値
(n+1)・Δy−Δxを格納するレジスタである。4
3は描画点数決定変数Dを格納する描画点数決定変数レ
ジスタで、初期値としては初期値算出部31から出力さ
れる値(n+1)・Δy−Δxが格納される。
Reference numeral 42 is a register that stores the value (n+1)·Δy−Δx output from the initial value calculation unit 31. 4
3 is a drawing point number determining variable register that stores the drawing point number determining variable D, and the value (n+1)·Δy−Δx output from the initial value calculation unit 31 is stored as an initial value.

【0020】44はレジスタ41の内容と描画点数決定
変数レジスタ43の内容とを加算する加算器である。4
5はレジスタ42の内容と描画点数決定変数レジスタ4
3の内容とを加算する加算器である。46は後述する描
画点数決定変数・描画点数制御部47からの切り換え制
御信号に基づいて、加算器44・45の加算結果のうち
の一方を選択出力し、描画点数決定変数レジスタ43の
内容を更新する加算値選択器である。
Reference numeral 44 denotes an adder that adds the contents of the register 41 and the contents of the drawing point number determining variable register 43. 4
5 is the contents of register 42 and drawing point number determination variable register 4
This is an adder that adds the contents of 3. 46 selects and outputs one of the addition results of the adders 44 and 45 based on a switching control signal from a drawing point number determining variable/drawing point number control unit 47, which will be described later, and updates the contents of the drawing point number determining variable register 43. This is an additional value selector.

【0021】47は描画点数決定変数Dの符号sに基づ
いて、上記加算値選択器46への切り換え制御信号、お
よびx軸方向の描画点数nまたはn+1を出力する描画
点数決定変数・描画点数制御部である。48は描画点数
決定変数・描画点数制御部47から出力される描画点数
nまたはn+1に直線幅hを乗じて出力する描画点数補
正部である。なお、描画する直線幅hが1の場合には、
描画点数決定変数・描画点数制御部47から出力された
値nまたはn+1がそのまま出力されることになる。
47 is a drawing point number determining variable/drawing point number control which outputs a switching control signal to the addition value selector 46 and the number of drawing points n or n+1 in the x-axis direction based on the sign s of the drawing point number determining variable D. Department. Reference numeral 48 denotes a drawing point number correction section which multiplies the drawing point number n or n+1 outputted from the drawing point number determination variable/drawing point number control section 47 by the straight line width h and outputs the result. Note that if the width h of the straight line to be drawn is 1,
The value n or n+1 output from the drawing point number determining variable/drawing point number control unit 47 is output as is.

【0022】49は後述する水平線描画部51で描画さ
れる水平線の端点のx座標を格納するレジスタで、初期
値としては初期値補正部から出力される値x1−(h−
1)・n/2が格納される。50は水平線描画部51で
描画される水平線のy座標を格納するレジスタで、初期
値としては値y1が格納される。
Reference numeral 49 is a register for storing the x coordinate of the end point of a horizontal line drawn by the horizontal line drawing section 51, which will be described later.
1)·n/2 is stored. A register 50 stores the y-coordinate of a horizontal line drawn by the horizontal line drawing unit 51, and the value y1 is stored as an initial value.

【0023】51はレジスタ49・50の内容、および
描画点数補正部48から出力される描画点数n・hまた
は(n+1)・hに基づいて、x軸方向の水平線の描画
を行う水平線描画部である。この水平線描画部51は、
また、レジスタ49の内容を上記描画点数決定変数・描
画点数制御部47から出力された値nまたはn+1だけ
加算した値に更新するとともに、レジスタ50の内容を
1だけ加算した値に更新するようになっている。
Reference numeral 51 denotes a horizontal line drawing section that draws a horizontal line in the x-axis direction based on the contents of the registers 49 and 50 and the number of drawing points n.h or (n+1).h output from the drawing point number correction section 48. be. This horizontal line drawing section 51 is
Also, the contents of the register 49 are updated to the value n output from the drawing point number determination variable/drawing point number control section 47 or a value obtained by adding n+1, and the contents of the register 50 are updated to a value obtained by adding 1. It has become.

【0024】61は上記水平線の描画回数である変数l
oopの値を格納するレジスタで、初期値として値Δy
が格納される。62は上記描画部40の動作を制御する
制御部で、起動信号が入力されてから、水平線の描画が
1回行われるごとにレジスタ61に格納されている変数
loopの値を1だけ減じ、この値が0になったときに
、描画動作を停止させるようになっている。
61 is the variable l which is the number of times the horizontal line is drawn.
This is a register that stores the value of oop, and the value Δy is set as the initial value.
is stored. Reference numeral 62 denotes a control unit that controls the operation of the drawing unit 40, which subtracts the value of the variable loop stored in the register 61 by 1 every time a horizontal line is drawn once after the activation signal is input, and When the value becomes 0, the drawing operation is stopped.

【0025】上記の構成において、制御部62に起動信
号が入力されたときに直線描画装置で行われる動作を図
2に示すフローチャートに基づいて説明する。まず、初
期値算出部31は、入力される値Δx、Δyに基づいて
整数除算Δx/Δyの商nを算出し(S201)、さら
に、値n・Δy−Δx、および値(n+1)・Δy−Δ
xを算出して、レジスタ41〜43に格納する(S20
2)。
In the above configuration, the operation performed by the linear drawing device when the activation signal is input to the control section 62 will be explained based on the flowchart shown in FIG. First, the initial value calculation unit 31 calculates the quotient n of the integer division Δx/Δy based on the input values Δx and Δy (S201), and further calculates the value n・Δy−Δx and the value (n+1)・Δy −Δ
Calculate x and store it in registers 41 to 43 (S20
2).

【0026】一方、初期値補正部32は、値x1−(h
−1)・n/2を算出してレジスタ49に格納し、また
、レジスタ50・61には、それぞれ値y1、Δyが格
納される(S203)。次に、描画点数決定変数・描画
点数制御部47が描画点数決定変数Dの符号を判別し(
S204)、負であれば、値n+1を描画点数として水
平線描画部51および描画点数補正部48に出力し、描
画点数補正部48は、値(n+1)・hを算出して水平
線描画部51に出力する。そこで、水平線描画部51は
座標(x,y)から座標(x+(n+1)・h−1,y
)までの水平線の描画を行った後(S205)、レジス
タ49に格納されている値(次に描画される水平線の端
点のx座標)をn+1だけ増加させる(S206)。 また、描画点数決定変数・描画点数制御部47は加算値
選択器46に加算器45を選択するように切り換え制御
信号を出力し、描画点数決定変数レジスタ43の内容は
(n+1)・Δy−Δxだけ増加した値に更新される(
S207)。
On the other hand, the initial value correction section 32 calculates the value x1-(h
-1)·n/2 is calculated and stored in the register 49, and the values y1 and Δy are stored in the registers 50 and 61, respectively (S203). Next, the drawing point number determining variable/drawing point number control unit 47 determines the sign of the drawing point number determining variable D (
S204), if negative, the value n+1 is output as the number of drawing points to the horizontal line drawing unit 51 and the number of drawing points correction unit 48, and the number of drawing points correction unit 48 calculates the value (n+1)·h and outputs it to the horizontal line drawing unit 51. Output. Therefore, the horizontal line drawing unit 51 moves from the coordinates (x, y) to the coordinates (x+(n+1)・h−1,y
) (S205), the value stored in the register 49 (the x-coordinate of the end point of the next horizontal line to be drawn) is increased by n+1 (S206). Further, the drawing point number determining variable/drawing point number control unit 47 outputs a switching control signal to the addition value selector 46 to select the adder 45, and the contents of the drawing point number determining variable register 43 are (n+1)・Δy−Δx will be updated to the value increased by (
S207).

【0027】ここで、上記水平線の描画は、より詳しく
は、例えば座標(x,y)から座標(x+(n+1)・
h−1,y)までの各座標ごとに、描画点に対応する図
示しない画像メモリのアドレスを生成し、そのアドレス
で示される記憶領域に描画データを書き込むことにより
行われる。このように、描画データの書き込みが描画点
1点ごとに行われる場合でも、加算器44・45による
加算処理等は、1本の水平線の描画につき1回行うだけ
でよいので、描画時間は短くてすむ。なお、画像メモリ
がバイトアクセスまたはワードアクセスされる場合には
、同一のバイトまたはワードに含まれる描画データは同
時に書き込むことができるので、画像メモリのアクセス
回数も少なくなり、一層、描画時間を短縮することがで
きる。
In more detail, the drawing of the horizontal line is, for example, from the coordinates (x, y) to the coordinates (x+(n+1)·
This is performed by generating an address of an image memory (not shown) corresponding to the drawing point for each coordinate up to h-1, y), and writing drawing data into a storage area indicated by the address. In this way, even when the drawing data is written for each drawing point, the addition process by the adders 44 and 45 only needs to be performed once for drawing one horizontal line, so the drawing time is short. I'll try it. Note that when the image memory is accessed by byte or word, the drawing data included in the same byte or word can be written simultaneously, which reduces the number of times the image memory is accessed, further shortening the drawing time. be able to.

【0028】一方、上記S204で描画点数決定変数D
が非負であれば、描画点数決定変数・描画点数制御部4
7は値nを描画点数として出力し、描画点数補正部48
は値n・hを算出して出力し、水平線描画部51は座標
(x,y)から座標(x+n・h−1,y)までの水平
線の描画を行った後(S208)、レジスタ49に格納
されている値をnだけ増加させる(S209)。また、
描画点数決定変数・描画点数制御部47は加算値選択器
46に加算器44を選択するように切り換え制御信号を
出力し、描画点数決定変数レジスタ43の内容はn・Δ
y−Δxだけ増加した値に更新される(S210)。
On the other hand, in S204, the drawing point number determining variable D
If is non-negative, the drawing point number determination variable/drawing point number control unit 4
7 outputs the value n as the number of drawing points, and the drawing point number correction unit 48
calculates and outputs the value n・h, and the horizontal line drawing unit 51 draws a horizontal line from the coordinates (x, y) to the coordinates (x+n・h−1, y) (S208), and then stores the value in the register 49. The stored value is increased by n (S209). Also,
The drawing point number determining variable/drawing point number control unit 47 outputs a switching control signal to the addition value selector 46 to select the adder 44, and the contents of the drawing point number determining variable register 43 are n.Δ
The value is updated to a value increased by y-Δx (S210).

【0029】その後、水平線描画部51はレジスタ50
に格納されている値(次に描画される水平線のy座標)
を1だけ増加させる(S211)。また、制御部62は
レジスタ61に格納されている変数loopの値を1だ
け減少させ(S212)、loop=0かどうか、すな
わち、すべてのy座標の水平線が描画されたかどうかを
判定し(S213)、YESになるまで上記S204以
降を繰り返す。
After that, the horizontal line drawing section 51 registers the register 50.
The value stored in (y-coordinate of the next horizontal line to be drawn)
is increased by 1 (S211). In addition, the control unit 62 decreases the value of the variable loop stored in the register 61 by 1 (S212), and determines whether loop=0, that is, whether horizontal lines at all y coordinates have been drawn (S213). ), the steps from S204 onward are repeated until the result is YES.

【0030】上記の動作によって実際に描画される直線
の例を図3に示す。同図に示すように始点座標(0,0
)から終点座標(19,5)を結ぶ直線を描画する場合
、y座標方向の描画点の数は5+1=6であるから、6
本の水平線が描画されることになる。また、x座標方向
の描画点の数は19+1=20であり、20/6=3余
り2であるから、描画点数3の水平線4本と描画点数4
の水平線2本とを描画すれば同図に示すような直線が描
画される。
FIG. 3 shows an example of a straight line actually drawn by the above operation. As shown in the figure, the starting point coordinates (0, 0
) to the end point coordinates (19, 5), the number of drawing points in the y-coordinate direction is 5+1=6, so 6
The horizontal line of the book will be drawn. Also, the number of drawing points in the x-coordinate direction is 19+1=20, and 20/6=3 with a remainder of 2, so there are 4 horizontal lines with 3 drawing points and 4 drawing points.
If two horizontal lines are drawn, a straight line as shown in the figure will be drawn.

【0031】すなわち、上記のような動作によって、描
画点数決定変数Dの値は所定の周期および頻度で負の値
と非負の値とをとるように変化し、その負、非負に応じ
て3個または4個の水平線を描画することにより、始点
座標(0,0)から終点座標(19,5)を結ぶ直線が
描画される。また、描画する直線の幅を示す値hとして
2以上の値が設定された場合には、描画点数補正部48
によって水平線の描画点数がh倍されることにより、上
下に隣合う水平線の一部がオーバラップするので、所定
の幅の直線が描画される。また、初期値補正部32で、
レジスタ49に設定される初期値が値x1−(h−1)
・n/2に補正されることにより、水平線がx軸方向に
オフセットされるので、始点座標と終点座標が幅を持た
せた直線の軌跡の中央線に位置するようになる。なお、
描画点数をh倍したりすると始点や終点からはみ出す部
分が生じるが、このはみ出す部分は描画抑制手段を設け
て描画されないようにしてもよい。また、上記描画点数
をh倍するのに代えて、例えば
That is, by the above operation, the value of the drawing point number determining variable D changes to take a negative value and a non-negative value at a predetermined period and frequency, and three values are changed depending on whether it is negative or non-negative. Alternatively, by drawing four horizontal lines, a straight line connecting the starting point coordinates (0,0) to the ending point coordinates (19,5) is drawn. Further, if a value of 2 or more is set as the value h indicating the width of the straight line to be drawn, the number of drawing points correction unit 48
By multiplying the number of drawing points of the horizontal line by h, vertically adjacent horizontal lines partially overlap, so a straight line with a predetermined width is drawn. In addition, the initial value correction unit 32
The initial value set in the register 49 is the value x1-(h-1)
- By correcting to n/2, the horizontal line is offset in the x-axis direction, so that the starting point coordinates and the ending point coordinates are located at the center line of the linear locus with width. In addition,
If the number of drawing points is multiplied by h, some parts will protrude from the starting point and the ending point, but a drawing suppressing means may be provided to prevent these protruding parts from being drawn. Also, instead of multiplying the number of drawing points by h, for example,

【0032】[0032]

【数1】[Math 1]

【0033】するようにすれば、直線の幅を直線の勾配
に係わらずほぼ一定にすることもできるが、h倍で近似
させる方が描画速度の点では好ましい。以上のように、
x座標単位にx,y座標を毎回算出するのでなく、y座
標単位にx座標とy座標とが同時に変化する座標点のみ
を算出し、次の変化点までの距水平線を一度に描画する
ので、高速な直線描画が行われる。
If this is done, the width of the straight line can be made almost constant regardless of the gradient of the straight line, but it is preferable to approximate it by h times from the viewpoint of drawing speed. As mentioned above,
Instead of calculating the x and y coordinates in x coordinate units each time, it calculates only the coordinate points where the x and y coordinates change simultaneously in y coordinate units, and draws the distance horizontal line to the next changing point at once. , high-speed straight line drawing is performed.

【0034】また、描画点数を所定倍することにより、
任意の幅の直線を描画することも容易にできる。なお、
上記実施例ではx1<x2、y1<y2、かつ直線の傾
きが0から1の間である例を示したが、直線の傾きによ
って場合分けし、傾きが1よりも大きい場合には、上記
x座標とy座標との関係を逆転させて処理するようにす
れば、あらゆる傾きの直線を描画することができる。
Furthermore, by multiplying the number of drawing points by a predetermined value,
It is also easy to draw straight lines of any width. In addition,
In the above embodiment, an example was shown in which x1<x2, y1<y2, and the slope of the straight line is between 0 and 1. By reversing the relationship between the coordinates and the y-coordinate, it is possible to draw straight lines with any inclination.

【0035】また、描画点数決定変数Dの値を評価する
ことにより、描画点数をnまたはn+1に決定するよう
に構成した例を示したが、これに限らず、例えば描画回
数を計数するカウンタを備え、整数除算Δx/Δyの商
nと余りとに応じて、所定の回数ずつ描画点数をnまた
はn+1に切り換えるように構成してもよい。この場合
には、各水平線を描画するごとに加算や判定等の処理を
行う必要もないので、一層高速な描画を行わせることが
できる。
Furthermore, although an example has been shown in which the number of drawing points is determined to be n or n+1 by evaluating the value of the drawing point number determining variable D, the present invention is not limited to this. In addition, the number of drawing points may be switched to n or n+1 a predetermined number of times depending on the quotient n and the remainder of the integer division Δx/Δy. In this case, there is no need to perform processes such as addition and determination each time each horizontal line is drawn, so that drawing can be performed even faster.

【0036】また、上記実施例では始点から終点までの
すべての水平線の描画点数がnまたはn+1になるよう
に描画する例を示したが、この場合、必ずしも始点と終
点とを幾何学的に結ぶ仮想直線に最も近い点が描画され
ないことがある。その場合でも大幅にずれた点が描画さ
れることはないので、通常のグラフィックス表示システ
ム等には充分適用可能である。
Furthermore, in the above embodiment, an example was shown in which the number of drawing points of all horizontal lines from the starting point to the ending point is n or n+1, but in this case, it is not necessary to connect the starting point and the ending point geometrically. The point closest to the virtual line may not be drawn. Even in that case, points that are significantly shifted will not be drawn, so it is fully applicable to ordinary graphics display systems.

【0037】但し、より幾何学的な仮想直線に沿ったも
のにするためには、例えば始点または終点を含む水平線
の描画点数を次のように設定して描画するようにすれば
よい。すなわち、整数除算Δx/Δyが割り切れ、しか
も商nが偶数の場合には、始点または終点を含む水平線
の描画点数をそれぞれn/2またはn/2+1に設定し
、その間の座標(x1+n/2,y1+1)から座標(
x2−n/2−1,y2−1)、または座標(x1+n
/2+1,y1+1)から座標(x2−n/2,y2−
1)の描画点までを上記のようにして描画する一方、整
数除算Δx/Δyが割り切れないか、または商nが奇数
の場合には、始点または終点を含む水平線の描画点数を
共にn/2+1に設定し、その間の座標(x1+n/2
+1,y1+1)から座標(x2−n/2−1,y2−
1)の描画点までを上記のようにして描画するように構
成すればよい。
However, in order to make the horizontal line follow a more geometrical virtual straight line, for example, the number of drawing points of the horizontal line including the starting point or the ending point may be set as follows. That is, if the integer division Δx/Δy is divisible and the quotient n is an even number, the number of drawing points of the horizontal line including the starting point or the ending point is set to n/2 or n/2+1, respectively, and the coordinates (x1+n/2, y1+1) to coordinates (
x2-n/2-1, y2-1), or coordinates (x1+n
/2+1, y1+1) to the coordinates (x2-n/2, y2-
While drawing up to the drawing point in 1) as above, if the integer division Δx/Δy is not divisible or the quotient n is an odd number, the number of drawing points of the horizontal line including the start point or the end point is both n/2 + 1. and the coordinates between them (x1+n/2
+1, y1+1) to coordinates (x2-n/2-1, y2-
The configuration may be such that up to the drawing point 1) is drawn as described above.

【0038】[0038]

【発明の効果】以上説明したように、本発明によれば、
第1の座標軸および第2の座標軸のうち、始点と終点間
の座標軸方向の描画点数が小さい方の座標軸における始
点と終点間の各座標値ごとに、他方の座標軸方向の所定
の個数の描画点から成る部分直線を描画する座標軸方向
部分直線描画手段を備えていることにより、一方の座標
値が同一の描画点は、1回の描画処理を行うだけでよい
ので、直線の描画に要する時間を大幅に短縮することが
できるという効果を奏する。
[Effects of the Invention] As explained above, according to the present invention,
A predetermined number of drawing points in the direction of the other coordinate axis for each coordinate value between the start point and the end point in the coordinate axis with the smaller number of drawing points in the direction of the coordinate axis between the start point and the end point of the first coordinate axis and the second coordinate axis. By providing partial straight line drawing means in the coordinate axis direction that draws a partial straight line consisting of This has the effect that it can be significantly shortened.

【図面の簡単な説明】[Brief explanation of the drawing]

【図1】直線描画装置の構成を示すブロック図である。FIG. 1 is a block diagram showing the configuration of a straight line drawing device.

【図2】直線描画装置で行われる動作を示すフローチャ
ートである。
FIG. 2 is a flowchart showing operations performed by the linear drawing device.

【図3】描画される直線の例を示す説明図である。FIG. 3 is an explanatory diagram showing an example of drawn straight lines.

【図4】従来の直線を描画するアルゴリズムを示すフロ
ーチャートである。
FIG. 4 is a flowchart showing a conventional algorithm for drawing straight lines.

【図5】同アルゴリズムが適用された直線描画装置の構
成を示すブロック図である。
FIG. 5 is a block diagram showing the configuration of a straight line drawing device to which the same algorithm is applied.

【符号の説明】[Explanation of symbols]

31    初期値算出部 32    初期値補正部 40    描画部 41・42・49・50・61  レジスタ43   
 描画点数決定変数レジスタ44・45  加算器 46    加算値選択器 47    描画点数決定変数・描画点数制御部48 
   描画点数補正部 51    水平線描画部 62    制御部
31 Initial value calculation section 32 Initial value correction section 40 Drawing section 41, 42, 49, 50, 61 Register 43
Number of drawing points determining variable registers 44 and 45 Adder 46 Addition value selector 47 Number of drawing points determining variable/number of drawing points control unit 48
Drawing point number correction section 51 Horizontal line drawing section 62 Control section

Claims (7)

【特許請求の範囲】[Claims] 【請求項1】  始点と終点とを結ぶ直線を描画する直
線描画装置において、第1の座標軸および第2の座標軸
のうち、始点と終点間の座標軸方向の描画点数が小さい
方の座標軸における始点と終点間の各座標値ごとに、他
方の座標軸方向の所定の個数の描画点から成る部分直線
を描画する座標軸方向部分直線描画手段を備えたことを
特徴とする直線描画装置。
Claim 1: In a straight line drawing device that draws a straight line connecting a starting point and an ending point, the starting point and A straight line drawing device comprising a partial straight line drawing means in a coordinate axis direction for drawing a partial straight line consisting of a predetermined number of drawing points in the other coordinate axis direction for each coordinate value between end points.
【請求項2】  請求項1の直線描画装置であって、さ
らに、前記部分直線に含まれる描画点の個数を、始点と
終点間の各座標軸方向の描画点数における多い方の描画
点数を少ない方の描画点数で整数除算した商に等しい第
1の個数か、または前記商よりも1だけ多い第2の個数
に設定する描画点数設定手段と、前記第1の個数の描画
点から成る部分直線を描画する回数と、第2の個数の描
画点から成る部分直線を描画する回数との比が、前記整
数除算における被除数と余りとの比にほぼ等しくなるよ
うに制御する部分直線描画制御手段とを備えたことを特
徴とする直線描画装置。
2. The straight line drawing device according to claim 1, further comprising: reducing the number of drawing points included in the partial straight line from the larger number of drawing points in each coordinate axis direction between the starting point and the end point to the smaller number of drawing points. a first number equal to a quotient obtained by dividing an integer by the number of drawing points, or a second number that is one more than the quotient, and a partial straight line consisting of the first number of drawing points; partial straight line drawing control means for controlling the ratio of the number of times of drawing and the number of times of drawing a partial straight line consisting of a second number of drawing points to be approximately equal to the ratio of the dividend to the remainder in the integer division; A straight line drawing device characterized by:
【請求項3】  請求項2の直線描画装置であって、さ
らに、初期描画点数として、前記第1の個数のほぼ1/
2の個数を設定する初期描画点数設定手段を備えたこと
を特徴とする直線描画装置。
3. The linear drawing device according to claim 2, further comprising: an initial number of drawing points approximately 1/1 of the first number;
1. A straight line drawing device comprising an initial drawing point number setting means for setting the number of points.
【請求項4】  請求項2の直線描画装置であって、さ
らに、始点を含む、始点と終点間の座標軸方向の描画点
数が大きい方の座標軸方向の部分直線であって、始点と
終点とを結ぶ仮想直線との他方の座標軸方向の距離が、
隣接する描画点間の距離の1/2よりも小さい描画点か
ら成る部分直線を描画する初期部分直線描画手段を備え
たことを特徴とする直線描画装置。
4. The straight line drawing device according to claim 2, further comprising a partial straight line in the direction of the coordinate axis between the start point and the end point, which has a larger number of drawing points in the direction of the coordinate axis between the start point and the end point. The distance in the direction of the other coordinate axis from the connecting virtual straight line is
A straight line drawing device comprising initial partial straight line drawing means for drawing a partial straight line consisting of drawing points whose distance is smaller than 1/2 of the distance between adjacent drawing points.
【請求項5】  請求項2の直線描画装置における描画
点数設定手段に代えて、前記部分直線に含まれる描画点
の個数を、前記整数除算の商の所定倍に等しい第1の個
数か、または前記商よりも1だけ多い数の所定倍の第2
の個数に設定する描画点数設定手段を備えたことを特徴
とする直線描画装置。
5. In place of the drawing point number setting means in the straight line drawing device of claim 2, the number of drawing points included in the partial straight line is set to a first number equal to a predetermined multiple of the quotient of the integer division, or the second of a predetermined multiple of a number that is one more than the quotient;
A straight line drawing device comprising a drawing point number setting means for setting the number of drawing points to the number of drawing points.
【請求項6】  座標が(x1,y1)である始点と、
座標が(x2,y2)である終点とを結ぶ直線を描画す
る直線描画装置において、 値Δx=x2−x1+1、および値Δy=y2−y1+
1に基づいて、整数除算Δx/Δyの商n、値n・Δy
−Δx、および値(n+1)・Δy−Δxを算出する初
期値算出手段と、前記値n・Δy−Δxを格納する第1
のレジスタと、前記値(n+1)・Δy−Δxを格納す
る第2のレジスタと、初期値として前記値(n+1)・
Δy−Δxを格納する第3のレジスタと、初期値として
前記始点座標値x1、およびy1をそれぞれ格納する第
4のレジスタ、および第5のレジスタと、前記値Δyを
格納する第6のレジスタと、前記第1のレジスタの内容
、および第2のレジスタの内容に、それぞれ第3のレジ
スタの内容を加算する第1の加算器、および第2の加算
器と、前記第1の加算器、または第2の加算器の加算結
果のうち、いずれか一方を選択的に切り換えて前記第3
のレジスタに出力し、格納させる選択器と、前記第3の
レジスタに格納されている値の符号に基づいて、前記選
択器に切り換え制御信号を出力するとともに、値がnま
たはn+1のx軸方向の描画点数を出力する切り換え・
描画点数制御手段と、前記切り換え・描画点数制御手段
から出力される描画点数、前記第4のレジスタの内容、
および第5のレジスタの内容に基づいて、x軸方向の直
線を描画するとともに、前記第4のレジスタおよび第5
のレジスタの内容を、それぞれ前記加算結果、および第
5のレジスタの内容に1だけ加算した値に更新するx軸
方向直線描画手段と、前記第6のレジスタの内容を1だ
け減算し、減算結果が0になるまで、前記各部の動作を
繰り返し行わせる制御手段とを備えたことを特徴とする
直線描画装置。
[Claim 6] A starting point whose coordinates are (x1, y1);
In a line drawing device that draws a straight line connecting an end point whose coordinates are (x2, y2), the value Δx=x2-x1+1 and the value Δy=y2-y1+
Based on 1, the quotient n of integer division Δx/Δy, the value n・Δy
−Δx, and an initial value calculating means for calculating the value (n+1)・Δy−Δx, and a first value calculating means for calculating the value n・Δy−Δx
a second register that stores the value (n+1)・Δy−Δx, and a second register that stores the value (n+1)・Δy−Δx as an initial value.
A third register that stores Δy−Δx, a fourth register that stores the starting point coordinate values x1 and y1 as initial values, and a fifth register, and a sixth register that stores the value Δy. , a first adder and a second adder that add the contents of a third register to the contents of the first register and the second register, respectively, and the first adder, or One of the addition results of the second adder is selectively switched to the third adder.
a selector that outputs and stores the value in the third register; outputs a switching control signal to the selector based on the sign of the value stored in the third register; Switching to output the number of drawing points
a drawing point number control means, the number of drawing points output from the switching/drawing point number control means, the contents of the fourth register,
and a straight line in the x-axis direction based on the contents of the fourth register and the fifth register.
x-axis direction straight line drawing means for updating the contents of the registers to a value obtained by adding 1 to the addition result and the contents of the fifth register, respectively; and subtracting the contents of the sixth register by 1, and A straight line drawing apparatus, comprising: a control means for repeatedly performing the operations of the respective parts until 0 becomes zero.
【請求項7】  請求項6の直線描画装置に加えて、描
画する直線の幅を示す値h、および前記初期値算出手段
から出力される商nに基づいて値x1−(h−1)・n
/2を算出し、算出結果を補正初期値として前記第4の
レジスタに格納させる初期値補正手段と、前記切り換え
・描画点数制御手段から出力される描画点数と前記値h
とを乗算し、積を補正描画点数として前記x軸方向直線
描画手段に出力する描画点数補正手段とを備えたことと
特徴とする直線描画装置。
7. In addition to the straight line drawing device according to claim 6, a value x1-(h-1).multidot. n
/2 and stores the calculation result in the fourth register as a corrected initial value; and the number of drawing points output from the switching/drawing point number control means and the value h.
A straight line drawing device comprising: a drawing point number correcting means for multiplying by the number of drawing points and outputting the product as a corrected drawing point number to the x-axis direction straight line drawing means.
JP12720591A 1991-05-30 1991-05-30 Straight line drawing device Pending JPH04352290A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP12720591A JPH04352290A (en) 1991-05-30 1991-05-30 Straight line drawing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP12720591A JPH04352290A (en) 1991-05-30 1991-05-30 Straight line drawing device

Publications (1)

Publication Number Publication Date
JPH04352290A true JPH04352290A (en) 1992-12-07

Family

ID=14954323

Family Applications (1)

Application Number Title Priority Date Filing Date
JP12720591A Pending JPH04352290A (en) 1991-05-30 1991-05-30 Straight line drawing device

Country Status (1)

Country Link
JP (1) JPH04352290A (en)

Similar Documents

Publication Publication Date Title
US4984183A (en) Graphics display controller for transferring figure data to overlapping portions of destination area and drawing-enable area defined by clipping rectangle
KR900006288B1 (en) Controller for display
JP2659614B2 (en) Display control device
JPH0214714B2 (en)
KR930005778B1 (en) Apparatus for processing of clipping image
US5299299A (en) Scan line full figure filling device for display units and printers
JPH04352290A (en) Straight line drawing device
JP3210141B2 (en) Straight line drawing device
JP2675169B2 (en) Graphic processing system
JP2947984B2 (en) Figure Drawing Method in Multiprocessor System
KR920002471B1 (en) Graphic controller
EP0357076A2 (en) Inclined rectangular pattern generating system
JP2594906B2 (en) Line type generation circuit in graphic processing equipment
JPH02308382A (en) Method and device for painting-out edge-emphasizing polygon
JPH11161255A (en) Image display unit
JP2787487B2 (en) Circuit for determining the position of a line segment displayed and operated on a computer system
JP2687429B2 (en) Graphic controller
JP2013156362A (en) Information processor and method for controlling the same
JPH0573256A (en) Crosshair cursor generating device
JPH0528771A (en) Memory element
JPH05205070A (en) Graphic plotting method
JPS62271186A (en) Graphic generating device
JPH10334251A (en) Fast plotting device
JP2006201331A (en) Digital image display method, digital image display apparatus, digital image display program and recording medium in which digital image display program is recorded
JPH01100589A (en) Segment lithography apparatus