0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

グラフ用パーツをEGGXで作る

Last updated at Posted at 2021-11-13

###内容
EGGXを使用し、グラフ用パーツ集を作りました。
###環境構築・インストール
環境構築とインストールは、「前の記事」に書きました。
##実行結果
image.png
##プログラム
コメント内の数字は、「日本語版ユーザーズガイド」の章番号をメモしてあります。

sample.c
/* [グラフ用パーツ集] 2021/11 by AN */

#include <eggx.h>
int main()
{
  int win;
  win = gopen(300, 600);        /*任意のサイズのグラフィックス画面を開く2.4.1*/
  winname(win, "graph sample"); /*ウィンドゥのタイトルを変更する2.4.5*/

  /*グラフ用紙*/

  drawarrow(win, 10, 10, 10, 590, 0.015, 0.01, 114); /*種々の型の矢印を描く2.4.37*/
  drawarrow(win, 10, 10, 290, 10, 0.03, 0.02, 114);

  /*グラフ*/

  drawline(win, 20, 560, 90, 560); /*直線の描画2.4.22 */

  newlinewidth(win, 3); /*線幅3 ---線幅の変更2.4.18*/
  drawline(win, 20, 540, 90, 540);

  newlinestyle(win, LineOnOffDash); /*点線 ---線のスタイルの変更2.4.19*/
  drawline(win, 20, 520, 90, 520);

  newlinestyle(win, LineSolid); /*実線 ---線のスタイルの変更2.4.19*/

  newpen(win, 15); /*描画色の変更2.4.13 */
  drawline(win, 20, 500, 90, 500);
  newpen(win, 14);
  drawline(win, 20, 480, 90, 480);
  newpen(win, 13);
  drawline(win, 20, 460, 90, 460);
  newpen(win, 12);
  drawline(win, 20, 440, 90, 440);
  newpen(win, 11);
  drawline(win, 20, 420, 90, 420);
  newpen(win, 10);
  drawline(win, 20, 400, 90, 400);
  newpen(win, 9);
  drawline(win, 20, 380, 90, 380);
  newpen(win, 8);
  drawline(win, 20, 360, 90, 360);
  newpen(win, 7);
  drawline(win, 20, 340, 90, 340);
  newpen(win, 6);
  drawline(win, 20, 320, 90, 320);
  newpen(win, 5);
  drawline(win, 20, 300, 90, 300);
  newpen(win, 4);
  drawline(win, 20, 280, 90, 280);
  newpen(win, 3);
  drawline(win, 20, 260, 90, 260);
  newpen(win, 2);
  drawline(win, 20, 240, 90, 240);
  newpen(win, 1);
  drawline(win, 20, 220, 90, 220);
  newpen(win, 0);
  drawline(win, 20, 200, 90, 200);
  newpen(win, 1);

  newlinewidth(win, 1); /*デフォルトに戻す ---線幅の変更 2.4.18 */

  drawrect(win, 20, 170, 70, 9); /*長方形を描く2.4.29*/

  fillrect(win, 20, 150, 70, 9); /*長方形の領域を塗り潰す2.4.30 */

  circle(win, 50, 125, 10, 10); /* 中心座標,半径を与えて円を描く2.4.31 */

  fillcirc(win, 50, 95, 10, 10); /*中心座標,半径を与えて円を塗り潰す2.4.32*/

  drawarc(win, 50, 70, 15, 15, 0.0, -180.0, -1); /*円の中心,半径,始点,終点の角度を与えて円弧を描く2.4.33*/

  fillarc(win, 50, 40, 15, 15, 0.0, -90.0, -1); /*円の中心,半径,始点,終点の角度を与えて円弧を塗り潰す2.4.34*/

  /*文字列の描画2.4.39*/

  drawstr(win, 20, 580, FONTSET, 0, "Y軸");
  drawstr(win, 270, 20, FONTSET, 0, "X軸");
  drawstr(win, 100, 560, FONTSET, 0, "線幅1");
  drawstr(win, 100, 540, FONTSET, 0, "線幅3");
  drawstr(win, 100, 520, FONTSET, 0, "点線");
  drawstr(win, 100, 500, FONTSET, 0, "15:黄(暗)");
  drawstr(win, 100, 480, FONTSET, 0, "14:マゼンタ(暗)");
  drawstr(win, 100, 460, FONTSET, 0, "13:シアン(暗)");
  drawstr(win, 100, 440, FONTSET, 0, "12:青(暗)");
  drawstr(win, 100, 420, FONTSET, 0, "11:緑(暗)");
  drawstr(win, 100, 400, FONTSET, 0, "10:赤(暗)");
  drawstr(win, 100, 380, FONTSET, 0, "9:灰色");
  drawstr(win, 100, 360, FONTSET, 0, "8:灰色(暗)");
  drawstr(win, 100, 340, FONTSET, 0, "7:黄");
  drawstr(win, 100, 320, FONTSET, 0, "6:マゼンタ");
  drawstr(win, 100, 300, FONTSET, 0, "5:シアン");
  drawstr(win, 100, 280, FONTSET, 0, "4:青");
  drawstr(win, 100, 260, FONTSET, 0, "3:緑");
  drawstr(win, 100, 240, FONTSET, 0, "2:赤");
  drawstr(win, 100, 220, FONTSET, 0, "1:白");
  drawstr(win, 100, 200, FONTSET, 0, "0:黒");
  drawstr(win, 100, 170, FONTSET, 0, "長方形");
  drawstr(win, 100, 150, FONTSET, 0, "長方形を塗り潰す");
  drawstr(win, 100, 120, FONTSET, 0, "円");
  drawstr(win, 100, 90, FONTSET, 0, "円を塗り潰す");
  drawstr(win, 100, 60, FONTSET, 0, "円弧");
  drawstr(win, 100, 30, FONTSET, 0, "円弧を塗り潰す");

  ggetch();    /*キー入力を待つ ---キーボードから入力された文字を返す2.4.48*/
  gclose(win); /*グラフィックス用ウィンドゥを閉じる2.4.2*/
  return 0;
}

####コンパイル用コマンド 

$ egg -o sample sample.c

####実行用コマンド

$ ./sample

##参考サイトリスト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?