S
S
samsungovetch2018-09-28 16:32:38
Pascal
samsungovetch, 2018-09-28 16:32:38

PascalABC - Brush movement mode without leaving a trail?

uses graphabc,crt,events;

var x,y:integer;
    c:char;
    drawmode: string;

const WH = 600;
      WW = 600;
      color_px = clBlack;

procedure draw_px(col:integer);
begin
  SetPenColor(col);
  SetBrushColor(col);
  rectangle(x,y,x+10,y+10)
end;



procedure kDown(key: integer); { ????????? ????????? ??????? ?????? }
begin
  if drawmode = 'no' then draw_px(clWhite);   //ðåæèì ëàñòèêà
  if key=VK_Left then x:=x-10; { ????? }
  if key=VK_Right then x:=x+10; { ?????? }
  if key=VK_Up then y:=y-10; { ????? }
  if key=VK_Down then y:=y+10; { ???? }
  if key=VK_Escape then CloseWindow; { ??????? ???? }
  if key=VK_Space then
     begin
      if drawmode = 'yes' then
        drawmode:='no'
      else
        if drawmode = 'no' then
           drawmode:='yes';
    end;
  if key=VK_Tab then
    begin
      if PenStyle = psClear then
        SetPenStyle(psSolid)
      else
        if PenStyle = psSolid then
          SetPenStyle(psClear);
    end;

  SetWindowCaption('x='+IntToStr(x)+' y='+IntToStr(y) + ' flag=' + drawmode );
  draw_px(clBlack);
end;


begin
  setWindowSize(WH,WW);
  x := WW div 2;
  y := WH div 2;
  drawmode:= 'yes';
  OnKeyDown:=kDown;

end.

Made two modes - drawing and erasing. How to do not drawing and not erasing, just moving the black square? They suggested that you can use the SetPenStyle (psClear) pen, but I don’t understand where to put it here. Help me please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2018-09-30
@samsungovetch

In the days of Turbo Pascal, I remember there was such an XOR drawing mode, which, when redrawing at the same coordinates, would draw pixels or erase them. This is possible when the image on the canvas has only black and white colors.
That is, before changing the coordinates, you need to "erase" the object, move and then draw in a new place.
I hope it helped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question