JunkBox_Lib 1.10.1
Loading...
Searching...
No Matches
window.c File Reference

グラフィック用ワールド座標系サポート More...

#include "window.h"
Include dependency graph for window.c:

Go to the source code of this file.

Functions

void setWindow (WSGraph vp, double x1, double y1, double x2, double y2)
 
void wSetPixel (WSGraph vp, double x, double y, int cc)
 
int wGetPixel (WSGraph vp, double x, double y)
 
void wLine (WSGraph vp, double x1, double y1, double x2, double y2, int cc)
 
void wMove (double x1, double y1)
 
void wDraw (WSGraph vp, double x1, double y1, int cc)
 
void wMove_Rel (double x1, double y1)
 
void wDraw_Rel (WSGraph vp, double x1, double y1, int cc)
 

Variables

double X_Dx
 ワールド座標系の x成分1ドットに対するスクリーン座標系のドット数.
 
double X_Dy
 ワールド座標系の y成分1ドットに対するスクリーン座標系のドット数.
 
double X_Wx
 スクリーン座標系の原点に対するワールド座標系の x成分.
 
double X_Wy
 スクリーン座標系の原点に対するワールド座標系の y成分.
 
double X_Now = 0.0
 ペンの現地点の x成分(ワールド座標系)
 
double Y_Now = 0.0
 ペンの現地点の y成分(ワールド座標系)
 

Detailed Description

Version
2.1
Author
Fumi.Iseki (C)

Definition in file window.c.

Function Documentation

◆ setWindow()

void setWindow ( WSGraph vp,
double x1,
double y1,
double x2,
double y2 )

void setWindow(WSGraph vp, double x1, double y1, double x2, double y2)

2Dのワールド座標系に表示用の窓(ビューポート)を設定する.

Parameters
vp窓(ビューポート)を割り付ける 2Dグラフィックデータ.
x1窓(ビューポート)の一つの角の座標の x成分.
y1窓(ビューポート)の一つの角の座標の y成分.
x2窓(ビューポート)の(x1,y1)の対角の座標の x成分.
y2窓(ビューポート)の(x1,y1)の対角の座標の y成分.

Definition at line 26 of file window.c.

27{
28 if (x1==x2 || y1==y2) return;
29
30 X_Dx = (vp.xs - 1)/Xabs(x2 - x1);
31 X_Dy = (vp.ys - 1)/Xabs(y2 - y1);
32 X_Wx = Min(x1, x2);
33 X_Wy = Max(y1, y2);
34}
#define Min(x, y)
Definition common.h:250
#define Max(x, y)
Definition common.h:247
#define Xabs(x)
Definition common.h:257
int xs
xサイズ. 4Byte.
Definition gdata.h:43
int ys
yサイズ. 4Byte.
Definition gdata.h:44
double X_Wy
スクリーン座標系の原点に対するワールド座標系の y成分.
Definition window.c:11
double X_Dy
ワールド座標系の y成分1ドットに対するスクリーン座標系のドット数.
Definition window.c:11
double X_Wx
スクリーン座標系の原点に対するワールド座標系の x成分.
Definition window.c:11
double X_Dx
ワールド座標系の x成分1ドットに対するスクリーン座標系のドット数.
Definition window.c:11

References Max, Min, X_Dx, X_Dy, X_Wx, X_Wy, Xabs, WSGraph::xs, and WSGraph::ys.

◆ wDraw()

void wDraw ( WSGraph vp,
double x1,
double y1,
int cc )

void wDraw(WSGraph vp, double x1, double y1, int cc)

ワールド座標系で現地点から指定した地点へ線を引く. 指定した地点が現地点となる.

Parameters
vp操作対象のグラフィックデータ.
x1線の終点の x座標(ワールド座標系).
y1線の終点の y座標(ワールド座標系).
cc線の輝度値.

Definition at line 131 of file window.c.

132{
133 wLine(vp, X_Now, Y_Now, x1, y1, cc);
134
135 X_Now = x1;
136 Y_Now = y1;
137}
double Y_Now
ペンの現地点の y成分(ワールド座標系)
Definition window.c:12
double X_Now
ペンの現地点の x成分(ワールド座標系)
Definition window.c:12
void wLine(WSGraph vp, double x1, double y1, double x2, double y2, int cc)
Definition window.c:92

References wLine(), X_Now, and Y_Now.

Here is the call graph for this function:

◆ wDraw_Rel()

void wDraw_Rel ( WSGraph vp,
double x1,
double y1,
int cc )

void wDraw_Rel(WSGraph vp, double x1, double y1, int cc)

ワールド座標系で現地点を起点として相対的に線を引く. 線の終点が現地点となる.

Parameters
vp操作対象のグラフィックデータ.
x1現地点から x方向への移動距離(ワールド座標系).
y1現地点から x方向への移動距離(ワールド座標系).
cc線の輝度値.

Definition at line 166 of file window.c.

167{
168 double x2, y2;
169
170 x2 = X_Now + x1;
171 y2 = Y_Now + y1;
172
173 wLine(vp, X_Now, Y_Now, x2, y2, cc);
174
175 X_Now = x2;
176 Y_Now = y2;
177}

References wLine(), X_Now, and Y_Now.

Here is the call graph for this function:

◆ wGetPixel()

int wGetPixel ( WSGraph vp,
double x,
double y )

int wGetPixel(WSGraph vp, double x, double y)

ワールド座標系に点を打つ.

Parameters
vp操作対象のグラフィックデータ.
x点の x座標(ワールド座標系).
y点の y座標(ワールド座標系).
Returns
点の輝度値.

Definition at line 69 of file window.c.

70{
71 int i, j;
72
73 i = (int)((x - X_Wx)*X_Dx + 0.5);
74 j = (int)((X_Wy - y)*X_Dy + 0.5);
75
76 return GetPixel(vp, i, j);
77}
#define GetPixel(vp, x, y)
Definition graph.h:92

References GetPixel, X_Dx, X_Dy, X_Wx, and X_Wy.

◆ wLine()

void wLine ( WSGraph vp,
double x1,
double y1,
double x2,
double y2,
int cc )

void wLine(WSGraph vp, double x1, double y1, double x2, double y2, int cc)

ワールド座標系に線を引く.

Parameters
vp操作対象のグラフィックデータ.
x1線の始点の x座標(ワールド座標系).
y1線の始点の y座標(ワールド座標系).
x2線の終点の x座標(ワールド座標系).
y2線の終点の y座標(ワールド座標系).
cc線の輝度値.

Definition at line 92 of file window.c.

93{
94 int i1, j1, i2, j2;
95
96 i1 = (int)((x1 - X_Wx)*X_Dx + 0.5);
97 i2 = (int)((x2 - X_Wx)*X_Dx + 0.5);
98 j1 = (int)((X_Wy - y1)*X_Dy + 0.5);
99 j2 = (int)((X_Wy - y2)*X_Dy + 0.5);
100
101 line(vp, i1, j1, i2, j2, cc);
102}
void line(WSGraph vp, int x1, int y1, int x2, int y2, int cc)
Definition graph.c:462

References line(), X_Dx, X_Dy, X_Wx, and X_Wy.

Referenced by wDraw(), and wDraw_Rel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wMove()

void wMove ( double x1,
double y1 )

void wMove(double x1, double y1)

ワールド座標系で現地点を移動する(線は引かない).

Parameters
x1移動する地点の x座標(ワールド座標系).
y1移動する地点の y座標(ワールド座標系).

Definition at line 113 of file window.c.

114{
115 X_Now = x1;
116 Y_Now = y1;
117}

References X_Now, and Y_Now.

◆ wMove_Rel()

void wMove_Rel ( double x1,
double y1 )

void wMove_Rel(double x1, double y1)

ワールド座標系で相対的に現地点を移動する(線は引かない).

Parameters
x1現地点から x方向への移動距離(ワールド座標系).
y1現地点から y方向への移動距離(ワールド座標系).

Definition at line 148 of file window.c.

149{
150 X_Now += x1;
151 Y_Now += y1;
152}

References X_Now, and Y_Now.

◆ wSetPixel()

void wSetPixel ( WSGraph vp,
double x,
double y,
int cc )

void wSetPixel(WSGraph vp, double x, double y, int cc)

ワールド座標系に点を打つ.

Parameters
vp操作対象のグラフィックデータ.
x点の x座標(ワールド座標系).
y点の y座標(ワールド座標系).
cc点の輝度値.

Definition at line 47 of file window.c.

48{
49 int i, j;
50
51 i = (int)((x - X_Wx)*X_Dx + 0.5);
52 j = (int)((X_Wy - y)*X_Dy + 0.5);
53
54 SetPixel(vp, i, j, cc);
55}
#define SetPixel(vp, x, y, cc)
Definition graph.h:72

References SetPixel, X_Dx, X_Dy, X_Wx, and X_Wy.

Variable Documentation

◆ X_Dx

double X_Dx

Definition at line 11 of file window.c.

Referenced by setWindow(), wGetPixel(), wLine(), and wSetPixel().

◆ X_Dy

double X_Dy

Definition at line 11 of file window.c.

Referenced by setWindow(), wGetPixel(), wLine(), and wSetPixel().

◆ X_Now

double X_Now = 0.0

Definition at line 12 of file window.c.

Referenced by wDraw(), wDraw_Rel(), wMove(), and wMove_Rel().

◆ X_Wx

double X_Wx

Definition at line 11 of file window.c.

Referenced by setWindow(), wGetPixel(), wLine(), and wSetPixel().

◆ X_Wy

double X_Wy

Definition at line 11 of file window.c.

Referenced by setWindow(), wGetPixel(), wLine(), and wSetPixel().

◆ Y_Now

double Y_Now = 0.0

Definition at line 12 of file window.c.

Referenced by wDraw(), wDraw_Rel(), wMove(), and wMove_Rel().