Answer the question
In order to leave comments, you need to log in
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.
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question