⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dither.c

📁 Intro/: Directory containing introductory examples. HelloWorld.c A simple program that draws a bo
💻 C
字号:
#include <phigs.h>			/* get HP-PHIGS definitions for C */#include <stdio.h>			/* get standard I/O definitions */main()					/* file "Dither.c" */{    Pint	WorkstnID = 1;		/* workstation identifier */    Pint	ConnID;			/* connection identifier */    Pint	WorkstnType = POIDDX;	/* out/in, direct, dbl bfr, Xwindow */    Pint	Structure = 1;		/* structure ID (chosen by user) */    Pcolr_rep	Black, White;		/* reduce colourmap to monochrome */    static Ptext_align TextAlignment = {PHOR_CTR, PVERT_TOP};    Ppoint	TextLoc;		/* where is the text located? */    Pgcolr	Colour;			/* colour of a particular tile */    int		I, Row, Tile;		/* loop control variables */    float	X, dX, Y;		/* for positioning tiles */    int		Tiles, Level;		/* temporary variables */    char	String[10];		/* for textual labels */    popen_phigs((char *) stderr, 0);	/* errors go to "stderr" */    pescape_u4("/dev/screen/phigs_window", &ConnID);    popen_ws(WorkstnID, (void *) ConnID, WorkstnType);    Black.rgb.red = Black.rgb.green = Black.rgb.blue = 0.0;   /* RGB: black */    White.rgb.red = White.rgb.green = White.rgb.blue = 1.0;   /* RGB: white */    pset_colr_rep(WorkstnID, 0, &Black);	/* colormap entry 0: black */    for (I = 1; I <= 255; I++) {	pset_colr_rep(WorkstnID, I, &White);	/* colormap entry I: white */    }    pescape_u250(WorkstnID, 0);		/* set colour environment */    pescape_u240(WorkstnID, 16);	/* set dither cell size */    /*---- define the structure ---------------------------------------------*/    popen_struct(Structure);	    pset_int_style(PSTYLE_SOLID);    pset_char_ht(0.03);    pset_text_align(&TextAlignment);    Level = 0;				/* start with 0% gray (black) */    for (Row = 1; Row <= 3; Row++) {	Tiles = 6;			/* usually six tiles per row */	dX = 0.0;			/* usually not shifted right */	if (Row == 2) {			/* however, in row two... */	    Tiles = 5;			/* ...there are only 5 tiles, */	    dX = 0.085;			/* ...shifted right a tad. */	}	for (Tile = 1; Tile <= Tiles; Tile++) {	    X = 0.17 * (Tile - 1) + dX;	/* define left edge */	    Y = 1.2 - Row * 0.3;	/* define top edge */	    Colour.colr_type = PCOLR_RGB;	    Colour.colr_value.colr_rep.rgb.red   = Level/16.0;	    Colour.colr_value.colr_rep.rgb.green = Level/16.0;	    Colour.colr_value.colr_rep.rgb.blue  = Level/16.0;	    pset_int_colr(&Colour);	    DoRectangle(X, Y, X + 0.15, Y - 0.15);	/* define the tile */	    sprintf(String, "%d/16", Level);	    TextLoc.x = X + 0.075;	    TextLoc.y = Y - 0.16;	    ptext(&TextLoc, String);	/* print the label */	    Level = Level + 1;		/* a little lighter next time */	}    }    pclose_struct();    ppost_struct(WorkstnID, Structure, 1.0);    pupd_ws(WorkstnID, PFLAG_PERFORM);	/* (regeneration flag) */    pclose_ws(WorkstnID);    pclose_phigs();}/****************************************************************************/DoRectangle(X1, Y1, X2, Y2)	/* define rectangle */float	X1, Y1;			/* first corner of rectangle */float	X2, Y2;			/* last corner of rectangle */{        Ppoint	TilePts[5];		/* holding the geometry of the tile */    Ppoint_list	Tile;			/* includes number of points */        TilePts[0].x = X1, TilePts[0].y = Y1;	/* lower left corner */    TilePts[1].x = X2, TilePts[1].y = Y1;	/* lower right corner */    TilePts[2].x = X2, TilePts[2].y = Y2;	/* upper right corner */    TilePts[3].x = X1, TilePts[3].y = Y2;	/* upper left corner */    TilePts[4].x = X1, TilePts[4].y = Y1;	/* for polyline's sake */    Tile.num_points = 4;    Tile.points = TilePts;    pfill_area(&Tile);			/* fill area */    Tile.num_points = 5;		/* \ polyline is needed because */    ppolyline(&Tile);			/* / pfill_area doesn't do edges */}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -