esercizi di grafica con turbo pascal 1.1 su mac

 

 

Program figure5;
{ disegna figure in cornice con RGNHANDLE }
{$U-}
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
      sfondo:pattern;
      regione:rgnhandle;
    
    procedure fine;
    begin
     sysbeep(1);
     moveto(10,20);
     drawstring('premi return per finire');
    end;
    
    procedure pausa;
    var a,tempo:integer;
      begin
       tempo:=500;
       for a:=1 to tempo do
         begin
          moveto(10,50);
          drawstring('attendere,prego');
         end;
      end;      
      
   procedure disegna;
     begin
     stuffhex(@sfondo,'1234567891234567');{ serie 16 numeri }
      regione:=newrgn;
      openrgn;
        showpen;   pausa;     
        setrect(vertici,260,270,460,350);{disegna cornice smussata}
        frameroundrect(vertici,24,16);pausa;
        
        moveto(275,335); {disegna triangolo}
        lineto(325,285);
        lineto(375,335);
        lineto(275,335);pausa;
        
        setrect(vertici,365,277,445,325);{ disegna ovale}
        frameoval(vertici);pausa;
        
        hidepen;
        closergn(regione);
        disposergn(regione);
      end;  
          
     
BEGIN
{inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);      
   initfonts;
   InitCursor;
   HideCursor;
   OpenPort(@gPort);   
   
{inizio programma principale}   
   PenPat(black);
   BackPat(white);
   EraseRect(gPort.portRect);
   FrameRect(gPort.portRect);
   { procedura operativa modificabile..altre procedure aggiungere }
   disegna;fine;
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.

 


Program figure6;
{ effetto attivazione o disattivazione routine grafiche inizializzazione }
{$U-}
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
          
    
    procedure fine;
    begin
     sysbeep(1);
     moveto(10,20);
     drawstring('premi return per finire');
    end;
    
    procedure pausa;
    var a,tempo:integer;
      begin
       tempo:=50;
       textface([shadow]);
       textsize(14);
       textfont(0);
       for a:=1 to tempo do
         begin
          moveto(10,50);
          drawstring('attendere,prego');
         end;
      end;      
      
 
 procedure disegna;
 begin
  setrect(vertici,50,50,200,200);
  framerect(vertici);
  pausa;
 end; 
       
          
BEGIN
{inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);      
   {initfonts;}{inizializza font:se eliminata ,gestione standard }
   {InitCursor;}{gestione visione bandierina cursore:appare o no }
   {HideCursor;}{gestione vidione bandierina cursore:appare o no }
   OpenPort(@gPort);  {SE assente ,si blocca computer... } 
   
{inizio programma principale}   
   {PenPat(black);} {gestione standard se assente }
   {BackPat(white);}{gestione standard se assente }
   EraseRect(gPort.portRect);{cancella listato a comando RUN }
   {FrameRect(gPort.portRect);}{se assente ,finestra standard }
   {--------------------------------------------------------------}
   { procedura operativa modificabile..altre procedure aggiungere }
   disegna;fine;
   {--------------------------------------------------------------}
   { attesa di return per finire }
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.

Program figure7;
{ effetto disattivazione routine grafiche inizializzazione }
{ iniz1alizzazione grafica MINIMA }
{$U-}
   USES Memtypes,QuickDraw,OSIntf,ToolIntf;
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
          
    
    procedure fine;
    begin
     sysbeep(1);
     moveto(10,20);
     drawstring('premi return per finire');
    end;
    
    procedure pausa;
    var a,tempo:integer;
      begin
       tempo:=50;
       textface([shadow]);
       textsize(14);
       textfont(0);
       for a:=1 to tempo do
         begin
          moveto(10,50);
          drawstring('attendere,prego');
         end;
      end;      
      
 
 procedure disegna;
 begin
  setrect(vertici,50,50,200,200);
  framerect(vertici);
  pausa;
 end; 
       
BEGIN
  {inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);         
   OpenPort(@gPort);  {SE assente ,si blocca computer... }    
  {inizio programma principale}     
   EraseRect(gPort.portRect);{cancella listato a comando RUN }   
   {--------------------------------------------------------------}
   { procedura operativa modificabile..altre procedure aggiungere }
   disegna;fine;
   {--------------------------------------------------------------}
   { attesa di return per finire }
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.

Program figure8;
{ effetto disattivazione routine grafiche inizializzazione }
{ iniz1alizzazione grafica MINIMA }
{$U-}
   USES Memtypes, quickdraw,OSIntf,ToolIntf;
   { OSIntf necessario per EVENTRECORD..sagoma ..attesa tasto }
   { ToolIntf necessario per INITFONTS ..:unico eliminabile }
   { Memtypes necessario per QuickDraw }
   { QuichDraw necessario per grafica }
   
   VAR
      gPort:   GrafPort;      
      sagoma: EventRecord;
      vertici:rect;
          
    
    procedure fine;
    begin
     sysbeep(1);
     moveto(10,20);
     drawstring('premi return per finire');
    end;
    
    procedure pausa;
    var a,tempo:integer;
      begin
       tempo:=50;
       textface([shadow]);
       textsize(14);
       textfont(0);
       for a:=1 to tempo do
         begin
          moveto(10,50);
          drawstring('attendere,prego');
         end;
      end;      
      
 
 procedure disegna;
 begin
  setrect(vertici,50,50,200,200);
  framerect(vertici);
  pausa;
 end; 
       
BEGIN
  {inizializzazione sottoprogrammi o routine}
   InitGraf(@thePort);         
   OpenPort(@gPort);  {SE assente ,si blocca computer... }    
  {inizio programma principale}     
   EraseRect(gPort.portRect);{cancella listato a comando RUN }   
   {--------------------------------------------------------------}
   { procedura operativa modificabile..altre procedure aggiungere }
   disegna;fine;
   {--------------------------------------------------------------}
   { attesa di return per finire }
   WHILE NOT OSEventAvail(mDownMask + keyDownMask, sagoma) DO;
END.