void draw_grill (int x) { int y = 0; while (y < WINHEIGHT - 4) { y += 3; draw_dot (x + 3, y); draw_dot (x, y); } }
static void sadtarrow_draw(Sadtarrow *sadtarrow, DiaRenderer *renderer) { DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer); NewOrthConn *orth = &sadtarrow->orth; Point *points; int n; Color col; Arrow arrow; points = &orth->points[0]; n = orth->numpoints; renderer_ops->set_linewidth(renderer, ARROW_LINE_WIDTH); renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID); renderer_ops->set_linecaps(renderer, LINECAPS_BUTT); col = ARROW_COLOR; if (sadtarrow->autogray && (orth->orientation[0] == VERTICAL) && (orth->orientation[orth->numpoints-2] == VERTICAL)) { col.red = GBASE + (GMULT*col.red); col.green = GBASE + (GMULT*col.green); col.blue = GBASE + (GMULT*col.blue); } arrow.type = ARROW_HEAD_TYPE; arrow.length = ARROW_HEAD_LENGTH; arrow.width = ARROW_HEAD_WIDTH; renderer_ops->draw_rounded_polyline_with_arrows (renderer, points, n, ARROW_LINE_WIDTH, &col, sadtarrow->style == SADT_ARROW_DOTTED?&arrow:NULL, sadtarrow->style != SADT_ARROW_DISABLED?&arrow:NULL, ARROW_CORNER_RADIUS); /* Draw the extra stuff. */ switch (sadtarrow->style) { case SADT_ARROW_IMPORTED: draw_tunnel(renderer,&points[0],&points[1],&col); break; case SADT_ARROW_IMPLIED: draw_tunnel(renderer,&points[n-1],&points[n-2],&col); break; case SADT_ARROW_DOTTED: draw_dot(renderer,&points[n-1], &points[n-2],&col); draw_dot(renderer,&points[0], &points[1],&col); break; case SADT_ARROW_NORMAL: case SADT_ARROW_DISABLED: break; } }
static void draw_line(AudioVectorScopeContext *s, int x0, int y0, int x1, int y1) { int dx = FFABS(x1-x0), sx = x0 < x1 ? 1 : -1; int dy = FFABS(y1-y0), sy = y0 < y1 ? 1 : -1; int err = (dx>dy ? dx : -dy) / 2, e2; for (;;) { draw_dot(s, x0, y0); if (x0 == x1 && y0 == y1) break; e2 = err; if (e2 >-dx) { err -= dy; x0 += sx; } if (e2 < dy) { err += dx; y0 += sy; } } }
// turn all the dots "off" in the ticker void Ticker::clear() { for(int i=0;i<20;i++) // maj_column for(int j=0;j<5;j++) // min_column for(int k=0;k<6;k++) // row draw_dot(i,j,k,0); // Clears the dot Flush(); current_char = ' '; // so we don't draw half of a zombie glyph }
void draw_parabola_x(PFBDEV pFbdev, POINT center, int a, uint8_t r, uint8_t g, uint8_t b) { int x; POINT p; for(x = center.x - 100; x < center.x + 100; x++) { p.x = x; p.y = (x - center.x) * (x - center.x) / a + center.y; draw_dot(pFbdev, p, r, g, b); } }
void draw_parabola_y(PFBDEV pFbdev, POINT center, int a, uint8_t r, uint8_t g, uint8_t b) { int y; POINT p; for(y = center.y - 100; y < center.y + 100; y++) { p.y = y; p.x = (y - center.y) * (y - center.y) / a + center.x; draw_dot(pFbdev, p, r, g, b); } }
void draw_img(IMG *ip){ Color img_buf[128]; int i, j; for(i = 0; i < ip->height; i++){ readline(ip, img_buf); for(j = 0; j < ip->width; j++){ draw_dot(j, 127-i, &img_buf[j]); } } }
void draw_line(PFBDEV pFbdev, POINT p1, POINT p2, uint8_t r, uint8_t g, uint8_t b) { POINT p; int x, y; for(x = MIN(p1.x, p2.x); x <= MAX(p1.x, p2.x); x++) { y = (p2.y - p1.y) * (x - p1.x) / (p2.x - p1.x) + p1.y; p.x = x; p.y = y; draw_dot(pFbdev, p, r, g, b); } }
void draw_circle(PFBDEV pFbdev, POINT center, uint32_t radius, uint8_t r, uint8_t g, uint8_t b) { POINT p; int x, y, tmp; for(x = center.x - radius; x <= center.x + radius; x++) { p.x = x; tmp = sqrt(radius * radius - (x - center.x) * (x - center.x)); p.y = center.y + tmp; draw_dot(pFbdev, p, r, g, b); p.y = center.y - tmp; draw_dot(pFbdev, p, r, g, b); } for(y = center.y - radius; y <= center.y + radius; y++) { p.y = y; tmp = sqrt(radius * radius - (y - center.y) * (y - center.y)); p.x = center.x + tmp; draw_dot(pFbdev, p, r, g, b); p.x = center.x - tmp; draw_dot(pFbdev, p, r, g, b); } }
void draw_fractal(t_env *e) { int x; int y; int i; y = 0; while (y < HEIGHT) { x = 0; while (x < WIDTH) { i = switch_fractal(e, x, y); if (i < e->cam->maxit) draw_dot(e, x, y, hsv_to_rgb(((i + e->cam->color) % 256), 255, 255)); else draw_dot(e, x, y, 0); x++; } y++; } }
//填充一个矩形框 void fill_rec(PFBDEV pFbdev,POINT lu,POINT ld,POINT ru,POINT rd,uint8_t r,uint8_t g,uint8_t b) { int xlen = ru.x - lu.x; int ylen = ld.y - lu.y; int m,n; for(m = 0;m < ylen;m++){ for(n = 0;n < xlen;n++){ POINT p; p.x = lu.x + n; p.y = lu.y + m; draw_dot(pFbdev,p,r,g,b); } } }
void draw_all_vec4(t_app *app, t_obj *obj) { unsigned int i; float proj; proj = app->scene.cam.proj; i = 0; while (i < obj->nbr_vecs) { if (proj == 2) obj->vecs[i] = perspective_vec4(app, obj->vecs[i]); obj->vecs[i].z = (obj->vecs[i].z - app->scene.cam.near) / app->scene.cam.far; draw_dot(app, obj->vecs[i], obj); i++; } }
static void render_dots (GstAudioVisualizer * base, guint32 * vdata, gint16 * adata, guint num_samples) { guint i, s, x, y, ox, oy; gfloat dx, dy; guint w = GST_VIDEO_INFO_WIDTH (&base->vinfo); guint h = GST_VIDEO_INFO_HEIGHT (&base->vinfo); /* draw dots 1st channel x, 2nd channel y */ dx = w / 65536.0; ox = w / 2; dy = h / 65536.0; oy = h / 2; s = 0; for (i = 0; i < num_samples; i++) { x = (guint) (ox + (gfloat) adata[s++] * dx); y = (guint) (oy + (gfloat) adata[s++] * dy); draw_dot (vdata, x, y, w, 0x00FFFFFF); } }
void draw_one_dot (hf_struct_type *hf, pen_struct *pen, gint x, gint y, gdouble **gauss_list) { // Drawing a unique dot, usually for drawing the first or the last dot of a stroke // The remainder of the stroke is drawn with draw_continuous_line_by_dot draw_buf *d = pen->map->dr_buf; d->current_tail = (d->current_tail+1)%d->max_tail; (d->tail+d->current_tail)->x = x; (d->tail+d->current_tail)->y = y; pen->map->map_to_use = pen->map->data; // With a non-symmetrical pen tip, we postpone the first dot, // so that we can draw it with the right angle (given by 1st-2nd dots) if (pen->shape != NO_WAVE_SHAPE) { pen->map->dr_buf->delayed_dot = TRUE; return; } else draw_dot (hf, pen, x, y, gauss_list); }
static void render_dots (GstAudioVisualizer * base, guint32 * vdata, gint16 * adata, guint num_samples) { gint channels = GST_AUDIO_INFO_CHANNELS (&base->ainfo); guint i, c, s, x, y, oy; gfloat dx, dy; guint w = GST_VIDEO_INFO_WIDTH (&base->vinfo); guint h = GST_VIDEO_INFO_HEIGHT (&base->vinfo); /* draw dots */ dx = (gfloat) w / (gfloat) num_samples; dy = h / 65536.0; oy = h / 2; for (c = 0; c < channels; c++) { s = c; for (i = 0; i < num_samples; i++) { x = (guint) ((gfloat) i * dx); y = (guint) (oy + (gfloat) adata[s] * dy); s += channels; draw_dot (vdata, x, y, w, 0x00FFFFFF); } } }
void detect_gate( int *x, int *y, int *x1, int *y1, int *x2, int *y2, int color ) { int g_area; float aspect; double color_coef; *x = -1; *y = -1; for( int i = 0; i < gwidth-1; i += 20 ) { for( int j = gheight-1; j >= 0; j -= 20 ) { if( IS_AD_COLOR( 3*i, j, color ) ) { g_min_x = gwidth; g_max_x = 0; g_min_y = gheight; g_max_y = 0; correct_c = 0; memset( gate_min_low, 0, sizeof(gate_min_low) ); g_area = find_gate_area( i, j, color ); if( g_min_y != g_max_y ) aspect = (float) (g_max_x - g_min_x) / (g_max_y - g_min_y); else aspect = 0.0f; if( g_area > 20 && aspect > 0.5f && aspect < 7.0 && ( (double)correct_c / (double)g_area ) > 0.025 ) { if( color == BLUE ) color_coef = 1.5; else color_coef = 2.0; double min_area; if(g_max_y < 200) min_area = (0.3289*pow((double)g_max_y, 1.6197)) / (1.5*color_coef); else min_area = (0.3289*pow((double)g_max_y, 1.6197)) / (4.0*color_coef); double max_area = (0.3289*pow((double)g_max_y, 1.6197)) * 1.2; printf("%f\n", min_area); if( g_area < min_area || g_area > max_area ) break; *x = g_min_x + ( g_max_x - g_min_x ) / 2; *y = g_max_y; *x1 = g_min_x; *y1 = gate_min_low[ g_min_x / 5 + 2 ]; *x2 = g_max_x; *y2 = gate_min_low[ g_max_x / 5 - 2 ]; draw_gate_lines(); draw_dot( *x, *y ); if( *x1 > 5 && *x1 < gwidth - 5 && *y1 > 5 && *y1 < gheight - 5 ) draw_dot( *x1, *y1 ); if( *x2 > 5 && *x2 < gwidth - 5 && *y2 > 5 && *y2 < gheight - 5 ) draw_dot( *x2, *y2 ); return; } else break; } if( !(IS_COLOR( 3*i, j, GREEN )) && !(IS_COLOR( 3*i, j, WHITE )) && !(IS_COLOR( 3*i, j, BLACK )) ) break; /*data[j][3*i+0] = 255; data[j][3*i+1] = 255; data[j][3*i+2] = 255;*/ } } }
static inline void plot_freq(ShowFreqsContext *s, int ch, double a, int f, uint8_t fg[4], int *prev_y, AVFrame *out, AVFilterLink *outlink) { const int w = s->w; const float avg = s->avg_data[ch][f]; const float bsize = get_bsize(s, f); const int sx = get_sx(s, f); int end = outlink->h; int x, y, i; switch(s->ascale) { case AS_SQRT: a = 1.0 - sqrt(a); break; case AS_CBRT: a = 1.0 - cbrt(a); break; case AS_LOG: a = log(av_clipd(a, 1e-6, 1)) / log(1e-6); break; case AS_LINEAR: a = 1.0 - a; break; } switch (s->cmode) { case COMBINED: y = a * outlink->h - 1; break; case SEPARATE: end = (outlink->h / s->nb_channels) * (ch + 1); y = (outlink->h / s->nb_channels) * ch + a * (outlink->h / s->nb_channels) - 1; break; } if (y < 0) return; switch (s->avg) { case 0: y = s->avg_data[ch][f] = !outlink->frame_count ? y : FFMIN(avg, y); break; case 1: break; default: s->avg_data[ch][f] = avg + y * (y - avg) / (FFMIN(outlink->frame_count + 1, s->avg) * y); y = s->avg_data[ch][f]; break; } switch(s->mode) { case LINE: if (*prev_y == -1) { *prev_y = y; } if (y <= *prev_y) { for (x = sx + 1; x < sx + bsize && x < w; x++) draw_dot(out, x, y, fg); for (i = y; i <= *prev_y; i++) draw_dot(out, sx, i, fg); } else { for (i = *prev_y; i <= y; i++) draw_dot(out, sx, i, fg); for (x = sx + 1; x < sx + bsize && x < w; x++) draw_dot(out, x, i - 1, fg); } *prev_y = y; break; case BAR: for (x = sx; x < sx + bsize && x < w; x++) for (i = y; i < end; i++) draw_dot(out, x, i, fg); break; case DOT: for (x = sx; x < sx + bsize && x < w; x++) draw_dot(out, x, y, fg); break; } }
static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; DrawGraphContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVDictionary *metadata; AVDictionaryEntry *e; AVFrame *out = s->out; int i; if (!s->out || s->out->width != outlink->w || s->out->height != outlink->h) { av_frame_free(&s->out); s->out = ff_get_video_buffer(outlink, outlink->w, outlink->h); out = s->out; if (!s->out) { av_frame_free(&in); return AVERROR(ENOMEM); } clear_image(s, out, outlink); } av_frame_copy_props(out, in); metadata = av_frame_get_metadata(in); for (i = 0; i < 4; i++) { double values[VAR_VARS_NB]; int j, y, x, old; uint32_t fg, bg; float vf; e = av_dict_get(metadata, s->key[i], NULL, 0); if (!e || !e->value) continue; if (sscanf(e->value, "%f", &vf) != 1) continue; vf = av_clipf(vf, s->min, s->max); values[VAR_MIN] = s->min; values[VAR_MAX] = s->max; values[VAR_VAL] = vf; fg = av_expr_eval(s->fg_expr[i], values, NULL); bg = AV_RN32(s->bg); if (i == 0 && s->x >= outlink->w) { if (s->slide == 0 || s->slide == 1) s->x = 0; if (s->slide == 2) { s->x = outlink->w - 1; for (j = 0; j < outlink->h; j++) { memmove(out->data[0] + j * out->linesize[0] , out->data[0] + j * out->linesize[0] + 4, (outlink->w - 1) * 4); } } else if (s->slide == 0) { clear_image(s, out, outlink); } } x = s->x; y = (outlink->h - 1) * (1 - ((vf - s->min) / (s->max - s->min))); switch (s->mode) { case 0: if (i == 0 && (s->slide == 1 || s->slide == 2)) for (j = 0; j < outlink->h; j++) draw_dot(bg, x, j, out); old = AV_RN32(out->data[0] + y * out->linesize[0] + x * 4); for (j = y; j < outlink->h; j++) { if (old != bg && (AV_RN32(out->data[0] + j * out->linesize[0] + x * 4) != old) || AV_RN32(out->data[0] + FFMIN(j+1, outlink->h - 1) * out->linesize[0] + x * 4) != old) { draw_dot(fg, x, j, out); break; } draw_dot(fg, x, j, out); } break; case 1: if (i == 0 && (s->slide == 1 || s->slide == 2)) for (j = 0; j < outlink->h; j++) draw_dot(bg, x, j, out); draw_dot(fg, x, y, out); break; case 2: if (s->first) { s->first = 0; s->prev_y[i] = y; } if (i == 0 && (s->slide == 1 || s->slide == 2)) { for (j = 0; j < y; j++) draw_dot(bg, x, j, out); for (j = outlink->h - 1; j > y; j--) draw_dot(bg, x, j, out); } if (y <= s->prev_y[i]) { for (j = y; j <= s->prev_y[i]; j++) draw_dot(fg, x, j, out); } else { for (j = s->prev_y[i]; j <= y; j++) draw_dot(fg, x, j, out); } s->prev_y[i] = y; break; } } s->x++; av_frame_free(&in); return ff_filter_frame(outlink, av_frame_clone(s->out)); }
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; AudioVectorScopeContext *s = ctx->priv; const int hw = s->hw; const int hh = s->hh; unsigned x, y; unsigned prev_x = s->prev_x, prev_y = s->prev_y; const double zoom = s->zoom; int i; if (!s->outpicref || s->outpicref->width != outlink->w || s->outpicref->height != outlink->h) { av_frame_free(&s->outpicref); s->outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!s->outpicref) { av_frame_free(&insamples); return AVERROR(ENOMEM); } for (i = 0; i < outlink->h; i++) memset(s->outpicref->data[0] + i * s->outpicref->linesize[0], 0, outlink->w * 4); } s->outpicref->pts = insamples->pts; fade(s); switch (insamples->format) { case AV_SAMPLE_FMT_S16: for (i = 0; i < insamples->nb_samples; i++) { int16_t *src = (int16_t *)insamples->data[0] + i * 2; if (s->mode == LISSAJOUS) { x = ((src[1] - src[0]) * zoom / (float)(UINT16_MAX) + 1) * hw; y = (1.0 - (src[0] + src[1]) * zoom / (float)UINT16_MAX) * hh; } else if (s->mode == LISSAJOUS_XY) { x = (src[1] * zoom / (float)INT16_MAX + 1) * hw; y = (src[0] * zoom / (float)INT16_MAX + 1) * hh; } else { float sx, sy, cx, cy; sx = src[1] * zoom / (float)INT16_MAX; sy = src[0] * zoom / (float)INT16_MAX; cx = sx * sqrtf(1 - 0.5*sy*sy); cy = sy * sqrtf(1 - 0.5*sx*sx); x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7; y = s->h - s->h * fabsf(cx + cy) * .7; } if (s->draw == DOT) { draw_dot(s, x, y); } else { draw_line(s, x, y, prev_x, prev_y); } prev_x = x; prev_y = y; } break; case AV_SAMPLE_FMT_FLT: for (i = 0; i < insamples->nb_samples; i++) { float *src = (float *)insamples->data[0] + i * 2; if (s->mode == LISSAJOUS) { x = ((src[1] - src[0]) * zoom / 2 + 1) * hw; y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh; } else if (s->mode == LISSAJOUS_XY){ x = (src[1] * zoom + 1) * hw; y = (src[0] * zoom + 1) * hh; } else { float sx, sy, cx, cy; sx = src[1] * zoom; sy = src[0] * zoom; cx = sx * sqrtf(1 - 0.5 * sy * sy); cy = sy * sqrtf(1 - 0.5 * sx * sx); x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7; y = s->h - s->h * fabsf(cx + cy) * .7; } if (s->draw == DOT) { draw_dot(s, x, y); } else { draw_line(s, x, y, prev_x, prev_y); } prev_x = x; prev_y = y; } break; } s->prev_x = x, s->prev_y = y; av_frame_free(&insamples); return ff_filter_frame(outlink, av_frame_clone(s->outpicref)); }
gboolean draw_continuous_line_by_dot (hf_struct_type *hf, pen_struct *pen, gdouble begin_x, gdouble begin_y, gdouble *end_x_ptr, gdouble *end_y_ptr, gboolean draw_end, gdouble **gauss_list) { // Same concept as draw_hf_line in draw_hf.c // Draw in real coordinates (interpolated from (gdouble)) // Instead of drawing a HF, we draw a gaussian map, whose size is more versatile // We smooth progressively what is drawn // Return TRUE if something has been drawn, FALSE otherwise gint h, steps, map_size, i, j, ii; gdouble spacing, dist, dx, dy, end_x, end_y; gboolean wrap; map_struct *map; draw_buf *d; map = pen->map; d = map->dr_buf; // We force the map size to be odd map_size = 2*map->radius+1; end_x = *end_x_ptr; end_y = *end_y_ptr; if (hf->if_tiles==NULL) wrap = (pen->wrap==TILING_YES) || (pen->wrap==TILING_AUTO); else wrap = (pen->wrap==TILING_YES) || ((pen->wrap==TILING_AUTO) && *hf->if_tiles); // Radius is 0 for a size of 1, 1 for a size of 3... up to 127 for a size of 255 // Size should always be odd // Draw each dot from the last x,y // Won't draw the last (just before the mouse release) // spacing is the increment applied, in pixels, each time we draw a dot spacing = pen->spacing * (gdouble) map_size; dist = (gdouble) DIST2((gdouble) begin_x, (gdouble) begin_y, (gdouble) end_x, (gdouble) end_y); dx = spacing * ((gdouble) (end_x - begin_x)) / dist; dy = spacing * ((gdouble) (end_y - begin_y)) /dist ; steps = (gint) floor(dist/spacing); if (!steps) { // We return FALSE when there is nothing to draw, // so that the (begin_x, begin_y) coordinates are not changed // for the next line to draw return FALSE; } if (pen->shape != NO_WAVE_SHAPE) { rotate ( (gdouble) dx, (gdouble) dy, map->data, map->tmp, map_size, map_size, HF_TYPE_ID, OVERFLOW_ZERO); map->map_to_use = map->tmp; } else map->map_to_use = map->data; if (d->delayed_dot) { draw_dot (hf, pen, (d->tail+d->current_tail)->x, (d->tail+d->current_tail)->y, gauss_list); d->delayed_dot = FALSE; } // printf("DX: %5.2f; DY: %5.2f; shape: %d; symm: %d\n",dx,dy,pen->shape, pen->map->square_symmetry); for (h=1; h<=steps; h++) { end_x = begin_x + dx * (gdouble) h; end_y = begin_y + dy * (gdouble) h; if (pen->merge == SMOOTH_OP) map_convolve (map->map_to_use, map_size, map_size, hf->hf_buf, hf->max_x, hf->max_y, (gint) end_x, (gint) end_y, wrap, 100, gauss_list, TRUE); else { if (pen->overlap) { generalized_merge( (gpointer) map->map_to_use, HF_TYPE_ID, map_size, map_size, hf->hf_buf, HF_TYPE_ID, hf->max_x, hf->max_y, (gint) end_x, (gint) end_y, pen->merge, wrap, map->square_symmetry); } else { // 1. Translate the drawing buffer "under" the // current map (pen tip) // 2. Write in the drawing buffer // 3. Write the drawing buffer in the layer buffer translate_draw_buf (map, (gint) end_x, (gint) end_y, pen->shape); generalized_merge( (gpointer) map->map_to_use, HF_TYPE_ID, map_size, map_size, d->data, HF_TYPE_ID, d->size, d->size, d->size/2, d->size/2, ADD, FALSE, // no wrap pen->map->square_symmetry); generalized_merge( (gpointer) map->dr_buf->data, HF_TYPE_ID, d->size, d->size, hf->layer_buf, HF_TYPE_ID, hf->max_x, hf->max_y, (gint) end_x, (gint) end_y, MAX_MERGE, wrap, FALSE ); // square_symmetry } } } // The last dot drawn doesn't fall on the coordinates where the motion motify event was emitted, // so we must adjust these coordinates (*end_x_ptr) = end_x; (*end_y_ptr) = end_y; return TRUE; }
/* * Inlined static... insures this is 'really' inlined completely... * * Process one dot... * */ static inline void do_shot(struct shot *current_shot) { zero_beam(); /* reset beam to middle of screen */ if (current_shot->shot_counter > 0) /* is this shot active? */ { current_shot->shot_counter--; /* no?, than reduce counter... */ if (current_shot->shot_counter == 0) /* if 0... make active and set up */ { init_shot(current_shot); } return; /* next time shot will be active, */ } /* for now... return */ else { switch (current_shot->direction) /* process direction flag */ { case TO_HALF_THREE: { /* is dot out of bounds? */ if ((current_shot->x > 120) || (current_shot->y > 120) ) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } current_shot->x += current_shot->speed; current_shot->y += current_shot->speed; break; } case TO_THREE: { /* is dot out of bounds? */ if (current_shot->x > 120) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->x += current_shot->speed; break; } case TO_HALF_SIX: { /* is dot out of bounds? */ if ((current_shot->x > 120) || (current_shot->y < -120) ) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->x += current_shot->speed; current_shot->y -= current_shot->speed; break; } case TO_SIX: { /* is dot out of bounds? */ if (current_shot->y < -120) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->y -= current_shot->speed; break; } case TO_HALF_NINE: { /* is dot out of bounds? */ if ((current_shot->x < -120) || (current_shot->y < -120) ) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->x -= current_shot->speed; current_shot->y -= current_shot->speed; break; } case TO_NINE: { /* is dot out of bounds? */ if (current_shot->x < -120) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->x -= current_shot->speed; break; } case TO_HALF_TWELF: { /* is dot out of bounds? */ if ((current_shot->x < -120) || (current_shot->y > 120) ) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->x -= current_shot->speed; current_shot->y += current_shot->speed; break; } case TO_TWELF: { /* is dot out of bounds? */ if (current_shot->y > 120) { /* yep, than make inactive and reset 'timer' */ current_shot->shot_counter = SHOT_INTERVALL; /* and bye */ return; } /* otherwise process coordinated according to direction and speed */ current_shot->y += current_shot->speed; break; } default: { /* oops... something wrong... make this false dot inactive ... */ current_shot->shot_counter = SHOT_INTERVALL; return; } } } /* now draw the dot */ write_ram(Vec_Dot_Dwell, DOT_BRIGHTNESS); /* first set up the dot dwell time */ set_scale(SHOT_SCALE); /* set scale for positioning */ draw_dot(current_shot->x, current_shot->y); /* position and draw the dot */ }
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; AudioVectorScopeContext *s = ctx->priv; const int hw = s->hw; const int hh = s->hh; unsigned x, y; const double zoom = s->zoom; int i; if (!s->outpicref || s->outpicref->width != outlink->w || s->outpicref->height != outlink->h) { av_frame_free(&s->outpicref); s->outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!s->outpicref) { av_frame_free(&insamples); return AVERROR(ENOMEM); } for (i = 0; i < outlink->h; i++) memset(s->outpicref->data[0] + i * s->outpicref->linesize[0], 0, outlink->w * 4); } s->outpicref->pts = insamples->pts; fade(s); switch (insamples->format) { case AV_SAMPLE_FMT_S16: for (i = 0; i < insamples->nb_samples; i++) { int16_t *src = (int16_t *)insamples->data[0] + i * 2; if (s->mode == LISSAJOUS) { x = ((src[1] - src[0]) * zoom / (float)(UINT16_MAX) + 1) * hw; y = (1.0 - (src[0] + src[1]) * zoom / (float)UINT16_MAX) * hh; } else { x = (src[1] * zoom / (float)INT16_MAX + 1) * hw; y = (src[0] * zoom / (float)INT16_MAX + 1) * hh; } draw_dot(s, x, y); } break; case AV_SAMPLE_FMT_FLT: for (i = 0; i < insamples->nb_samples; i++) { float *src = (float *)insamples->data[0] + i * 2; if (s->mode == LISSAJOUS) { x = ((src[1] - src[0]) * zoom / 2 + 1) * hw; y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh; } else { x = (src[1] * zoom + 1) * hw; y = (src[0] * zoom + 1) * hh; } draw_dot(s, x, y); } break; } av_frame_free(&insamples); return ff_filter_frame(outlink, av_frame_clone(s->outpicref)); }