Beispiel #1
0
bool GUIDrawLine( gui_window *wnd, gui_point *start, gui_point *end,
                  gui_line_styles style, gui_ord thickness, gui_attr attr )
{
    gui_point   my_start;
    gui_point   my_end;
    SAREA       area;
    char        to_use;

    /* unused parameters */ (void)style; (void)thickness;

    my_start = *start;
    my_end = *end;
    GUIScaleToScreenRPt( &my_start );
    GUIScaleToScreenRPt( &my_end );

    area.row = my_start.y;
    area.height = my_end.y - my_start.y + 1;
    area.col = my_start.x;
    area.width = my_end.x - my_start.x + 1;

    if( my_start.x == my_end.x ) {
        to_use = DRAW( VERT_FRAME );
    } else {
        if( my_start.y == my_end.y ) {
            to_use = DRAW( HOR_FRAME );
        } else {
            return( false );
        }
    }
    if( AdjustRect( wnd, &area ) ) {
        uivfill( &wnd->screen, area, wnd->colours[attr], to_use );
    }
    return( true );
}
Beispiel #2
0
static int
mask_draw_labq( Mask *mask )
{
	float *lab_buffer;
	float ink_buffer[3];
	int y;

	if( !(lab_buffer = IM_ARRAY( NULL, 
		mask->image_clip.width * 3, float )) )
		return( -1 );

	imb_LabQ2Lab( DRAW( mask )->ink, ink_buffer, 1 );

	for( y = 0; y < mask->image_clip.height; y++ ) {
		PEL *to = (PEL *) IM_IMAGE_ADDR( DRAW( mask )->im, 
			mask->image_clip.left, y + mask->image_clip.top );
		PEL *mask_line = (PEL *) IM_IMAGE_ADDR( mask->mask_im, 
			mask->mask_clip.left, y + mask->mask_clip.top );

		imb_LabQ2Lab( to, lab_buffer, mask->image_clip.width );
		DBLEND( float, lab_buffer, ink_buffer );
		imb_Lab2LabQ( lab_buffer, to, mask->image_clip.width );
	}

	im_free( lab_buffer );

	return( 0 );
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	UNUSED(argc); UNUSED(argv);
	int exit_status = EXIT_FAILURE;
	bit quit = 0;
	SDL_Event e;

	INIT_SDL();

	sprite_sheet = LOAD_TEXTURE("sdl/sprite_sheet.png");

	DRAW();
	while (!quit) {
		SDL_WAITEVENT(&e);
		if (e.type == SDL_QUIT)
			quit = 1;
		else if (e.type == SDL_KEYDOWN) {
			key_down(e.key.keysym.sym);
			DRAW();
		}
	}

	exit_status = EXIT_SUCCESS;
error:
	SDL_DestroyTexture(sprite_sheet);
	close_sdl();
	exit(exit_status);
}
Beispiel #4
0
static void WriteTopCalLine(void)
{
    gon();
    DRAW(br);
    PrintCentered("", CalWidth-2, linestruct->lr);
    DRAW(bl);
    goff();
    PutChar('\n');
}
Beispiel #5
0
static void
squaretate (eraser_state *st)
{
  int max = ((st->width > st->height ? st->width : st->height) * 2);
  XPoint points [3];
  int i = max * st->ratio;

  if (st->ratio == 0.0)
    st->flip_p = random() & 1;
    
# define DRAW()						\
  if (st->flip_p) {					\
    points[0].x = st->width - points[0].x;		\
    points[1].x = st->width - points[1].x;		\
    points[2].x = st->width - points[2].x;		\
  }							\
  XFillPolygon (st->dpy, st->window, st->bg_gc,		\
		points, 3, Convex, CoordModeOrigin)

  points[0].x = 0;
  points[0].y = 0;
  points[1].x = st->width;
  points[1].y = 0;
  points[2].x = 0;
  points[2].y = points[0].y + ((i * st->height) / max);
  DRAW();

  points[0].x = 0;
  points[0].y = 0;
  points[1].x = 0;
  points[1].y = st->height;
  points[2].x = ((i * st->width) / max);
  points[2].y = st->height;
  DRAW();

  points[0].x = st->width;
  points[0].y = st->height;
  points[1].x = 0;
  points[1].y = st->height;
  points[2].x = st->width;
  points[2].y = st->height - ((i * st->height) / max);
  DRAW();

  points[0].x = st->width;
  points[0].y = st->height;
  points[1].x = st->width;
  points[1].y = 0;
  points[2].x = st->width - ((i * st->width) / max);
  points[2].y = 0;
  DRAW();
# undef DRAW
}
Beispiel #6
0
static void WriteWeekHeaderLine(void)
{
    int i;
    gon();
    DRAW(br);
    for (i=0; i<7; i++) {
	PrintCentered("", ColSpaces, linestruct->lr);
	if (i != 6) {
	    DRAW(blr);
	} else {
	    DRAW(bl);
	}
    }
    goff();
    PutChar('\n');
}
Beispiel #7
0
static void WriteBottomCalLine(void)
{
    int i;
    gon();
    DRAW(tr);
    for (i=0; i<7; i++) {
	PrintCentered("", ColSpaces, linestruct->lr);
	if (i != 6) {
	    DRAW(tlr);
	} else {
	    DRAW(tl);
	}
    }
    goff();
    PutChar('\n');
}
void DisplayChannel::handle_draw_copy(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawCopy* copy = (SpiceMsgDisplayDrawCopy*)message->data();
    canvas = surfaces_mngr.get_canvas(copy->base.surface_id);
    DRAW(copy);
}
void DisplayChannel::handle_draw_stroke(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawStroke* stroke = (SpiceMsgDisplayDrawStroke*)message->data();
    canvas = surfaces_mngr.get_canvas(stroke->base.surface_id);
    DRAW(stroke);
}
Beispiel #10
0
int main(int argc, char *argv[])
{
	UNUSED(argc); UNUSED(argv);
	int exit_status = EXIT_FAILURE;
	bit quit = 0;
	SDL_Event e;

	INIT_SDL();

	back = LOAD_TEXTURE("sdl/back.png");
	sprite_sheet = LOAD_TEXTURE("sdl/animation.png");

	while (!quit) {
		while (SDL_PollEvent(&e)) {
			if (e.type == SDL_QUIT)
				quit = 1;
		}
		input();
		DRAW();
	}

	exit_status = EXIT_SUCCESS;
error:
	SDL_DestroyTexture(back);
	SDL_DestroyTexture(sprite_sheet);
	close_sdl();
	exit(exit_status);
}
void DisplayChannel::handle_draw_alpha_blend(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawAlphaBlend* alpha_blend = (SpiceMsgDisplayDrawAlphaBlend*)message->data();
    canvas = surfaces_mngr.get_canvas(alpha_blend->base.surface_id);
    DRAW(alpha_blend);
}
void DisplayChannel::handle_draw_invers(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawInvers* invers = (SpiceMsgDisplayDrawInvers*)message->data();
    canvas = surfaces_mngr.get_canvas(invers->base.surface_id);
    DRAW(invers);
}
Beispiel #13
0
int main(int argc, char *argv[])
{
	UNUSED(argc); UNUSED(argv);
	int exit_status = EXIT_FAILURE;
	bit quit = 0;
	SDL_Event e;

	INIT_SDL();

	font1 = TTF_OPENFONT("sdl/OpenSans-Regular.ttf", 28);
	font2 = TTF_OPENFONT("sdl/OpenSans-Regular.ttf", 100);
	text1 = TEXTURE_FROM_TEXT(font1, "Press S to start / stop, P to pause / unpause.", (SDL_Color){0xFF, 0xFF, 0xFF, 0xFF});
	text3 = TEXTURE_FROM_TEXT(font2, "BOGOMETER", (SDL_Color){0xFF, 0x7F, 0x3F, 0xFF});

	while (!quit) {
		DRAW();
		if (SDL_PollEvent(&e)) {
			if (e.type == SDL_QUIT)
				quit = 1;
			else if (e.type == SDL_KEYDOWN)
				key_down(e.key.keysym.sym);
		}
	}

	exit_status = EXIT_SUCCESS;
error:
	SDL_DestroyTexture(text1);
	SDL_DestroyTexture(text3);
	TTF_CloseFont(font1);
	TTF_CloseFont(font2);
	close_sdl();
	exit(exit_status);
}
void DisplayChannel::handle_draw_rop3(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawRop3* rop3 = (SpiceMsgDisplayDrawRop3*)message->data();
    canvas = surfaces_mngr.get_canvas(rop3->base.surface_id);
    DRAW(rop3);
}
void DisplayChannel::handle_draw_opaque(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawOpaque* opaque = (SpiceMsgDisplayDrawOpaque*)message->data();
    canvas = surfaces_mngr.get_canvas(opaque->base.surface_id);
    DRAW(opaque);
}
void DisplayChannel::handle_draw_whiteness(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawWhiteness* whiteness = (SpiceMsgDisplayDrawWhiteness*)message->data();
    canvas = surfaces_mngr.get_canvas(whiteness->base.surface_id);
    DRAW(whiteness);
}
void DisplayChannel::handle_draw_fill(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawFill* fill = (SpiceMsgDisplayDrawFill*)message->data();
    canvas = surfaces_mngr.get_canvas(fill->base.surface_id);
    DRAW(fill);
}
Beispiel #18
0
static void
emit_gmem2mem_surf(struct fd_ringbuffer *ring, uint32_t swap, uint32_t base,
                   struct pipe_surface *psurf)
{
    struct fd_resource *rsc = fd_resource(psurf->texture);

    OUT_PKT3(ring, CP_SET_CONSTANT, 2);
    OUT_RING(ring, CP_REG(REG_RB_COLOR_INFO));
    OUT_RING(ring, RB_COLOR_INFO_COLOR_SWAP(swap) |
             RB_COLOR_INFO_COLOR_BASE(base / 1024) |
             RB_COLOR_INFO_COLOR_FORMAT(fd_pipe2color(psurf->format)));

    OUT_PKT3(ring, CP_SET_CONSTANT, 5);
    OUT_RING(ring, CP_REG(REG_RB_COPY_CONTROL));
    OUT_RING(ring, 0x00000000);             /* RB_COPY_CONTROL */
    OUT_RELOC(ring, rsc->bo, 0, 0);         /* RB_COPY_DEST_BASE */
    OUT_RING(ring, rsc->pitch >> 5);        /* RB_COPY_DEST_PITCH */
    OUT_RING(ring, RB_COPY_DEST_INFO_FORMAT(fd_pipe2color(psurf->format)) |
             RB_COPY_DEST_INFO_LINEAR |      /* RB_COPY_DEST_INFO */
             RB_COPY_DEST_INFO_SWAP(swap) |
             RB_COPY_DEST_INFO_WRITE_RED |
             RB_COPY_DEST_INFO_WRITE_GREEN |
             RB_COPY_DEST_INFO_WRITE_BLUE |
             RB_COPY_DEST_INFO_WRITE_ALPHA);

    OUT_PKT3(ring, CP_WAIT_FOR_IDLE, 1);
    OUT_RING(ring, 0x0000000);

    OUT_PKT3(ring, CP_DRAW_INDX, 3);
    OUT_RING(ring, 0x00000000);
    OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX,
                        INDEX_SIZE_IGN, IGNORE_VISIBILITY));
    OUT_RING(ring, 3);					/* NumIndices */
}
Beispiel #19
0
static void
emit_gmem2mem_surf(struct fd_ringbuffer *ring,
		enum adreno_rb_copy_control_mode mode,
		uint32_t base, struct pipe_surface *psurf)
{
	struct fd_resource *rsc = fd_resource(psurf->texture);

	OUT_PKT0(ring, REG_A3XX_RB_COPY_CONTROL, 4);
	OUT_RING(ring, A3XX_RB_COPY_CONTROL_MSAA_RESOLVE(MSAA_ONE) |
			A3XX_RB_COPY_CONTROL_MODE(mode) |
			A3XX_RB_COPY_CONTROL_GMEM_BASE(base));
	OUT_RELOCW(ring, rsc->bo, 0, 0, -1);    /* RB_COPY_DEST_BASE */
	OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(rsc->pitch * rsc->cpp));
	OUT_RING(ring, A3XX_RB_COPY_DEST_INFO_TILE(LINEAR) |
			A3XX_RB_COPY_DEST_INFO_FORMAT(fd3_pipe2color(psurf->format)) |
			A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE(0xf) |
			A3XX_RB_COPY_DEST_INFO_ENDIAN(ENDIAN_NONE) |
			A3XX_RB_COPY_DEST_INFO_SWAP(fd3_pipe2swap(psurf->format)));

	OUT_PKT3(ring, CP_DRAW_INDX, 3);
	OUT_RING(ring, 0x00000000);
	OUT_RING(ring, DRAW(DI_PT_RECTLIST, DI_SRC_SEL_AUTO_INDEX,
			INDEX_SIZE_IGN, IGNORE_VISIBILITY));
	OUT_RING(ring, 2);					/* NumIndices */
}
void DisplayChannel::handle_draw_transparent(RedPeer::InMessage* message)
{
    Canvas *canvas;
    SpiceMsgDisplayDrawTransparent* transparent = (SpiceMsgDisplayDrawTransparent*)message->data();
    canvas = surfaces_mngr.get_canvas(transparent->base.surface_id);
    DRAW(transparent);
}
Beispiel #21
0
static void WriteCalDays(void)
{
    int i;
    gon();
    DRAW(tb);
    goff();
    for (i=0; i<7; i++) {
	if (!MondayFirst)
	    PrintCentered(DayName[(i+6)%7], ColSpaces, " ");
	else
	    PrintCentered(DayName[i%7], ColSpaces, " ");
	gon();
	DRAW(tb);
	goff();
    }
    PutChar('\n');
}
Beispiel #22
0
/*
@description	Clears all resources associated with the DrawingWand.
*/
value nMagick_draw_clear( value draw )
{
	DrawingWand *drw;

	val_check_kind( draw, k_draw );

	drw = DRAW( draw );

	ClearDrawingWand( drw );
}
Beispiel #23
0
/**
 * im_draw_point:
 * @image: image to draw on
 * @x: position to draw
 * @y: position to draw
 * @ink: value to draw
 *
 * Draws a single point on an image. 
 *
 * @ink is an array of bytes containing a valid pixel for the image's format.
 * It must have at least IM_IMAGE_SIZEOF_PEL( @im ) bytes.
 *
 * See also: im_draw_line().
 *
 * Returns: 0 on success, or -1 on error.
 */
int
im_draw_point( VipsImage *image, int x, int y, VipsPel *ink )
{	
	Point point;

	if( im_check_coding_known( "im_draw_point", image ) ||
		im__draw_init( DRAW( &point ), image, NULL ) )
		return( -1 );

	/* Check coordinates.
	 */
	if( x >= 0 && x < image->Xsize && y >= 0 && y < image->Ysize ) 
		memcpy( IM_IMAGE_ADDR( image, x, y ), ink, 
			DRAW( image )->psize );

	im__draw_free( DRAW( &point ) );

	return( 0 );
}
Beispiel #24
0
/*
@description	Destroys the DrawingWand from memory.
*/
value nMagick_draw_destroy( value draw )
{
	DrawingWand *drw;

	val_check_kind( draw, k_draw );

	drw = DRAW( draw );

	DestroyDrawingWand( drw );
}
Beispiel #25
0
/*
@description	Deallocates resources associated with a PixelWand.
*/
value nMagick_draw_close( value draw )
{
	DrawingWand *drw;

	val_check_kind( draw, k_pixel );
	val_gc( draw, NULL );

	drw = DRAW( draw );

	DestroyDrawingWand( drw );
}
Beispiel #26
0
static int WriteOneCalLine(void)
{
    int done = 1, i;

    gon();
    DRAW(tb);
    goff();
    for (i=0; i<7; i++) {
	if (CalColumn[i]) {
	    if (WriteOneColLine(i)) done = 0;
	} else {
	    PrintCentered("", ColSpaces, " ");
	}
	gon();
	DRAW(tb);
	goff();
    }
    PutChar('\n');

    return done;
}
Beispiel #27
0
/*
@description	Returns an identical copy of the DrawingWand.
*/
value nMagick_draw_clone( value draw )
{
	value v;
	DrawingWand *drw;

	val_check_kind( draw, k_draw );

	drw = DRAW( draw );

	v = alloc_abstract( k_draw, CloneDrawingWand( drw ) );
	val_gc( v, nMagick_draw_close );
	return v;
}
Beispiel #28
0
static void WriteCalHeader(void)
{
    char buf[80];
    int y, m, d;

    FromJulian(JulianToday, &y, &m, &d);
    sprintf(buf, "%s %d", MonthName[m], y);

    WriteTopCalLine();

    gon();
    DRAW(tb);
    goff();
    PrintCentered(buf, CalWidth-2, " ");
    gon();
    DRAW(tb);
    goff();
    PutChar('\n');

    WritePostHeaderLine();
    WriteCalDays();
    WriteIntermediateCalLine();
}
Beispiel #29
0
void
tty_print_alt_char (int c, gboolean single)
{
#define DRAW(x, y) (x == y) \
       ? SLsmg_draw_object (SLsmg_get_row(), SLsmg_get_column(), x) \
       : SLsmg_write_char ((unsigned int) y)
    switch (c)
    {
    case ACS_VLINE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_VERT : MC_TTY_FRM_DVERT]);
        break;
    case ACS_HLINE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_HORIZ : MC_TTY_FRM_DHORIZ]);
        break;
    case ACS_LTEE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTMIDDLE : MC_TTY_FRM_DLEFTMIDDLE]);
        break;
    case ACS_RTEE:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTMIDDLE : MC_TTY_FRM_DRIGHTMIDDLE]);
        break;
    case ACS_ULCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTTOP : MC_TTY_FRM_DLEFTTOP]);
        break;
    case ACS_LLCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_LEFTBOTTOM : MC_TTY_FRM_DLEFTBOTTOM]);
        break;
    case ACS_URCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTTOP : MC_TTY_FRM_DRIGHTTOP]);
        break;
    case ACS_LRCORNER:
        DRAW (c, mc_tty_frm[single ? MC_TTY_FRM_RIGHTBOTTOM : MC_TTY_FRM_DRIGHTBOTTOM]);
        break;
    case ACS_PLUS:
        DRAW (c, mc_tty_frm[MC_TTY_FRM_CROSS]);
        break;
    default:
        SLsmg_write_char ((unsigned int) c);
    }
#undef DRAW
}
Beispiel #30
0
static Mask *
mask_new( VipsImage *im, int x, int y, PEL *ink, VipsImage *mask_im )
{
	Mask *mask;
	Rect area, image;

	if( im_check_coding_noneorlabq( "im_draw_mask", im ) ||
		im_incheck( mask_im ) ||
		im_check_mono( "im_draw_mask", mask_im ) ||
		im_check_uncoded( "im_draw_mask", mask_im ) ||
		im_check_format( "im_draw_mask", mask_im, IM_BANDFMT_UCHAR ) ||
		!(mask = IM_NEW( NULL, Mask )) )
		return( NULL );
	if( !im__draw_init( DRAW( mask ), im, ink ) ) {
		mask_free( mask );
		return( NULL );
	}

	mask->x = x;
	mask->y = y;
	mask->mask_im = mask_im;

	/* Find the area we draw on the image.
	 */
	area.left = x;
	area.top = y;
	area.width = mask_im->Xsize;
	area.height = mask_im->Ysize;
	image.left = 0;
	image.top = 0;
	image.width = im->Xsize;
	image.height = im->Ysize;
	im_rect_intersectrect( &area, &image, &mask->image_clip );

	/* And the area of the mask image we use.
	 */
	mask->mask_clip = mask->image_clip;
	mask->mask_clip.left -= x;
	mask->mask_clip.top -= y;

	return( mask );
}