La fonction d'animation, permet de déplacer un ou plusieurs élément(s) de la sélection, selon une direction, un nombre d'étapes et une distance de variation dans l'espace du Plan. Les couleurs passagères peuvent être représentées avec différentes intensités !

4 périodes d'une heure à la bibliothèque des «quatre piliers» pour réaliser ce mini-programme d'animation, de la sélection dans l'espace du plan.

Cette programmation d'une animation selon trois facteurs d'évolution dans l'espace du plan.

Par la suite, l'idée nous est venus de l'appliquer à une suite de vecteurs et de points selon la position de chacun d'eux avec un indice sur chacune des listes de tableaux..



unit Unit_animation;

interface

uses Windows,c_color,wbase,messages,dialbase,utile;

type

  TWin_animation = class(Wbase.TWindow)
    constructor Create(AParent:Wbase.TWindow);
    procedure   Setupwindow; override;
    procedure 	WMpaint(var msg:tmessage); override;
    procedure   WMCommand(var Msg:tmessage); override;
    procedure   Make_animation;
    procedure   Do_animation(ellapse:integer);
    procedure   Memoriser_l_etat_initiale;
    procedure   Revenir_a_l_etat_initial;
    procedure   Positionner_les_curseurs(var Msg: TMessage);
    procedure 	WMLButtonDown(var Msg: TMessage); override;
		procedure   WMLButtonUp(var Msg: TMessage); override;
		procedure   WMMOUSEMOVE(var msg:tmessage); override;
    procedure   WMTimer(var Msg: TMessage);	override;
    procedure   Animation_des_calques;
    procedure   WMClose(var msg:TMessage); override;
    procedure 	WMSet_painture_control(var Msg: TMessage); override;
    private
      angle:integer;
      down:boolean;
      offset,count:integer;
      timer_actif:boolean;
      variation_des_couleurs:boolean;
      color_one,color_two:tcolorref;
      color_one_picker:boolean;
      color_two_picker:boolean;
    end;

implementation

uses u_object,col_plan,wutil,wproche,unit_menu,g_base,wmain,
      wmenuk,deformat,U_fast_bitmap,haide,
      hls_rvb,sysutils,z_open_file,Dial_champs,
      GDIPAPI,gdipobj,Classes,relation,graphics,drawsym;
        {Ces unités avec ces définitions}

var rect_repetition : trect;
    rect_decalage : trect;
    rect_create_animation : trect;
    rect_lancer_animation : trect;
    rect_remise_a_zero : trect;
    rect_allow_color : trect;
    rect_color_one : trect;
    rect_color_two : trect;

const k_offset = 160;
      kid_animation = 1000;

constructor TWin_animation.Create(AParent:Wbase.TWindow);
  const k_window_size =180;
  begin
  inherited Create(AParent,'Animate',
    getsystemmetrics(SM_CXFULLSCREEN) div 2-k_window_size div 2,
    getsystemmetrics(SM_CYFULLSCREEN) div 2-k_window_size div 2,
      k_window_size,k_window_size+k_offset,True,false,0); {True pour l'exstyle}
  Self.Memoriser_l_etat_initiale;
  end; {TWin_animation.Create}

procedure TWin_animation.Setupwindow;
  begin
  inherited Setupwindow;
  self.angle:=90;
  self.down:=False;
  self.timer_actif:=False;
  self.offset:=10;
  self.count:=12;
  self.variation_des_couleurs:=false;
  self.color_one:=g_base.RGB_Bleu;
  self.color_two:=g_base.RGB_blanc;
  self.color_one_picker:=false;
  self.color_two_picker:=false;
  end;

procedure TWin_animation.WMpaint(var msg:tmessage);
  var i,j:integer;
      paintdc,memdc,memorydc:hdc;
      arect:trect;
      PaintStruct:TPaintStruct;
      une_distance,un_angulary:real;
      une_couleur:tcolorref;
      old_bitmap,old_deux_bitmap:hbitmap;
      apc:pc100;
      une_typo:hfont;
      abrush:hbrush;
      apoint:tpoint;
      Size:tsize;
      lr_angle_en_radian:real;
      graphics:gdipobj.TGPGraphics;
      pencil_vanille:TGPPen;
      faster:U_fast_bitmap.TFastBitmap2;
      bitmap:tbitmap;
      time_before:integer;
  begin
  time_before:=gettickcount;
  getcursorpos(apoint);
  screentoclient(self.hwindow,apoint);
  getclientrect(self.hwindow,arect);
  paintdc:=windows.beginpaint(self.hwindow,PaintStruct);
  memdc:=createcompatibledc(paintdc);
  with arect do old_bitmap:=selectobject(memdc,createcompatiblebitmap(paintdc,right,bottom));
  rectangle(memdc,-1,-1,succ(arect.right),succ(arect.bottom));
  if false then ellipse(paintdc,20,20,arect.right-20,arect.bottom-20);
  if true then
    begin
    with arect do faster.Creer(right,bottom);
    //Ceci pour dessiner la roue des couleurs un disque
    //Quelque soit la position d'un point si la distance de celui-ci
    //Par rapport au centre du cercle est inférieur au rayon le colorier.
    for i:=0 to arect.right do for j:=0 to arect.bottom-k_offset do
      begin
      une_distance:=utile.distance(i,j,arect.right div 2,(arect.bottom-k_offset) div 2);
      if une_distance<69 then //année érotique et celle de colas
        begin
        un_angulary:=angle_degree(arect.right div 2,(arect.bottom-k_offset) div 2,i,j);
        une_couleur:=hls_rvb.Get_HLS_RGB(un_angulary,0.76,1);
        faster.SetPixel(i,j,une_couleur); {Celle-ci est 10 fois plus rapide}
        end;
      end;
    memorydc:=createcompatibledc(paintdc);
    selectobject(memorydc,faster.Bmp.Handle);
    with arect do bitblt(memdc,0,0,right,bottom,memorydc,0,0,SRCCOPY);
    deletedc(memorydc);
    faster.Free;
    end
  else
    begin
    for i:=0 to arect.right do for j:=0 to arect.bottom-k_offset do
      begin
      une_distance:=utile.distance(i,j,arect.right div 2,(arect.bottom-k_offset) div 2);
      if une_distance<69 then //année érotique et celle de colas
        begin
        un_angulary:=angle_degree(arect.right div 2,(arect.bottom-k_offset) div 2,i,j);
        une_couleur:=hls_rvb.Get_HLS_RGB(un_angulary,0.76,1);
        setpixel(memdc,i,j,une_couleur); {cette fonction microsoft est trop lente}
        end;
      end;
    end;
  if true then
    drawsym.draw_help_twip(memdc,arect.right-20,4);
  lr_angle_en_radian:=self.angle*pi/180;
  if true then
    begin
    //Ceci pour dessiner la flèche d'indication de la direction de l'animation.
    graphics := gdipobj.TGPGraphics.Create(memdc);
    graphics.SetSmoothingMode(SmoothingModeAntiAlias);
    graphics.SetSmoothingMode(SmoothingModeHighQuality);
    pencil_vanille:=TGPPen.Create(MakeColor(255,0,0,0),1);
    graphics.DrawLine(pencil_vanille,
      arect.right div 2,(arect.bottom-k_offset) div 2,
      arect.right div 2+cos(lr_angle_en_radian)*70,
      (arect.bottom-k_offset) div 2-sin(lr_angle_en_radian)*70);
    graphics.DrawLine(pencil_vanille,
      arect.right div 2+round(cos(lr_angle_en_radian)*70),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*70),
      arect.right div 2+(cos(lr_angle_en_radian)*70+cos(lr_angle_en_radian+pi-pi/10)*12),
      (arect.bottom-k_offset) div 2-(sin(lr_angle_en_radian)*70+sin(lr_angle_en_radian+pi-pi/10)*12));
    graphics.DrawLine(pencil_vanille,
      arect.right div 2+cos(lr_angle_en_radian)*70+cos(lr_angle_en_radian+pi-pi/10)*12,
      (arect.bottom-k_offset) div 2-(sin(lr_angle_en_radian)*70+sin(lr_angle_en_radian+pi-pi/10)*12),
      arect.right div 2+round(cos(lr_angle_en_radian)*63),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*63));
    graphics.DrawLine(pencil_vanille,
      arect.right div 2+round(cos(lr_angle_en_radian)*70),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*70),
      arect.right div 2+(cos(lr_angle_en_radian)*70+cos(lr_angle_en_radian+pi+pi/10)*12),
      (arect.bottom-k_offset) div 2-(sin(lr_angle_en_radian)*70+sin(lr_angle_en_radian+pi+pi/10)*12));
    graphics.DrawLine(pencil_vanille,
      arect.right div 2+cos(lr_angle_en_radian)*70+cos(lr_angle_en_radian+pi+pi/10)*12,
      (arect.bottom-k_offset) div 2-(sin(lr_angle_en_radian)*70+sin(lr_angle_en_radian+pi+pi/10)*12),
      arect.right div 2+cos(lr_angle_en_radian)*63,
      (arect.bottom-k_offset) div 2-sin(lr_angle_en_radian)*63);
    pencil_vanille.Free;
    graphics.free;;
    end {written by denis Beelog le 15 september 2016, aucune équations en erreur}
  else
    begin
    moveto(memdc,arect.right div 2,(arect.bottom-k_offset) div 2);
    lineto(memdc,
      arect.right div 2+round(cos(lr_angle_en_radian)*70),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*70));
    lineto(memdc,
      arect.right div 2+round(cos(lr_angle_en_radian)*70+cos(lr_angle_en_radian+pi-pi/10)*12),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*70+sin(lr_angle_en_radian+pi-pi/10)*12));
    lineto(memdc,
      arect.right div 2+round(cos(lr_angle_en_radian)*65),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*65));
    moveto(memdc,
      arect.right div 2+round(cos(lr_angle_en_radian)*70),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*70));
    lineto(memdc,
      arect.right div 2+round(cos(lr_angle_en_radian)*70+cos(lr_angle_en_radian+pi+pi/10)*12),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*70+sin(lr_angle_en_radian+pi+pi/10)*12));
    lineto(memdc,
      arect.right div 2+round(cos(lr_angle_en_radian)*65),
      (arect.bottom-k_offset) div 2-round(sin(lr_angle_en_radian)*65));
    end;
  setbkmode(memdc,TRANSPARENT);
  inttopchar(self.angle,apc); strcat(apc,wutil.kpc_degree); //L'angle en degré
  une_typo:=selectobject(memdc,Get_MakeDefaultCalibri(22)); //La taille du corps de la typo
  textout(memdc,0,0,apc,strlen(apc));
  deleteobject(selectobject(memdc,une_typo));
  //Affichage du nombre de répétiton(s).
  une_typo:=selectobject(memdc,Get_MakeDefaultCalibri(12));
  settextcolor(memdc,g_base.RGB_Blanc);
  Textout(memdc,8,140,z_open_file.string_nombre_de_repetition,strlen(z_open_file.string_nombre_de_repetition));
  settextcolor(memdc,g_base.RGB_Noir);
  Textout(memdc,9,141,z_open_file.string_nombre_de_repetition,strlen(z_open_file.string_nombre_de_repetition));
  GetTextExtentPoint(memdc,z_open_file.string_nombre_de_repetition,strlen(z_open_file.string_nombre_de_repetition),Size);
  inttopchar(self.count,apc);
  Textout(memdc,9+size.cx,141,apc,strlen(apc));
  setrect(Unit_animation.rect_repetition,10,155,arect.right-10,165);
  with Unit_animation.rect_repetition do
    begin
    rectangle(memdc,left,top,right,bottom);
    abrush:=selectobject(memdc,createsolidbrush(g_base.rgb_rouge));
    rectangle(memdc,left+Self.count,top,left+Self.count+10,bottom);
    deleteobject(selectobject(memdc,abrush));
    end;
  //Affichage de la distance de décalage.
  settextcolor(memdc,g_base.RGB_Blanc);
  Textout(memdc,8,165,z_open_file.string_distance_de_decalage,strlen(z_open_file.string_distance_de_decalage));
  settextcolor(memdc,g_base.RGB_Noir);
  Textout(memdc,9,166,z_open_file.string_distance_de_decalage,strlen(z_open_file.string_distance_de_decalage));
  GetTextExtentPoint(memdc,z_open_file.string_distance_de_decalage,strlen(z_open_file.string_distance_de_decalage),Size);
  inttopchar(self.offset,apc);strcat(apc,'  (1/10 mm)');
  Textout(memdc,9+size.cx,165,apc,strlen(apc));
  deleteobject(selectobject(memdc,une_typo));
  setrect(Unit_animation.rect_decalage,10,180,arect.right-10,190);
  with Unit_animation.rect_decalage do
    begin
    rectangle(memdc,left,top,right,bottom);
    abrush:=selectobject(memdc,createsolidbrush(g_base.rgb_rouge));
    rectangle(memdc,left+Self.offset,top,left+Self.offset+10,bottom);
    deleteobject(selectobject(memdc,abrush));
    end;
  //Créer l'animation
  setrect(Unit_animation.rect_create_animation,20,195,arect.right-20,215);
  with Unit_animation.rect_create_animation do
    begin
    if ptinrect(Unit_animation.rect_create_animation,apoint) then
      begin
      settextcolor(memdc,g_base.RGB_Orange);
      Soft_rectangle(memdc,left,top,right,bottom,g_base.RGB_bleu);
      end
    else
      begin
      settextcolor(memdc,g_base.RGB_Noir);
      Soft_rectangle(memdc,left,top,right,bottom,g_base.RGB_Orange);
      end;
    une_typo:=selectobject(memdc,Get_MakeDefaultCalibri(18));
    Textout(memdc,left+2,top+2,
      z_open_file.string_create_animation,strlen(z_open_file.string_create_animation));
    deleteobject(selectobject(memdc,une_typo));
    end;
  //lancer l'animation
  setrect(Unit_animation.rect_lancer_animation,20,215,arect.right-20,235);
  with Unit_animation.rect_lancer_animation do
    begin
    if ptinrect(Unit_animation.rect_lancer_animation,apoint) then
      begin
      settextcolor(memdc,g_base.RGB_Orange);
      Soft_rectangle(memdc,left,top,right,bottom,g_base.RGB_bleu);
      end
    else
      begin
      settextcolor(memdc,g_base.RGB_Noir);
      Soft_rectangle(memdc,left,top,right,bottom,g_base.RGB_Orange);
      end;
    une_typo:=selectobject(memdc,Get_MakeDefaultCalibri(18));
    if not self.timer_actif then
      Textout(memdc,left+2,top+2,
        z_open_file.string_launch_animation,strlen(z_open_file.string_launch_animation))
    else
      Textout(memdc,left+2,top+2,
        z_open_file.string_stop_animation,strlen(z_open_file.string_stop_animation));
    deleteobject(selectobject(memdc,une_typo));
    end;
  //Remise à zéro
  setrect(Unit_animation.rect_remise_a_zero,10,240,arect.right-10,260);
  with Unit_animation.rect_remise_a_zero do
    begin
    if ptinrect(Unit_animation.rect_remise_a_zero,apoint) then
      begin
      settextcolor(memdc,g_base.RGB_Orange);
      Soft_rectangle(memdc,left,top,right,bottom,g_base.RGB_bleu);
      end
    else
      begin
      settextcolor(memdc,g_base.RGB_Noir);
      Soft_rectangle(memdc,left,top,right,bottom,g_base.RGB_Orange);
      end;
    une_typo:=selectobject(memdc,Get_MakeDefaultCalibri(18));
    if not self.timer_actif then
      Textout(memdc,left+2,top+2,
        z_open_file.string_remise_a_zero,strlen(z_open_file.string_remise_a_zero))
    else
      Textout(memdc,left+2,top+2,
        z_open_file.string_remise_a_zero,strlen(z_open_file.string_remise_a_zero));
    deleteobject(selectobject(memdc,une_typo));
    end;
  {Positionner les cases de variation des couleurs}
  setrect(rect_allow_color,10,270,32,290);
  with rect_allow_color do rectangle(memdc,left,top,right,bottom);
  if self.variation_des_couleurs then
    begin
    if true then
      begin
      graphics := gdipobj.TGPGraphics.Create(memdc);
      graphics.SetSmoothingMode(SmoothingModeAntiAlias);
      graphics.SetSmoothingMode(SmoothingModeHighQuality);
      pencil_vanille:=TGPPen.Create(MakeColor(255,0,0,0),1);
      with rect_allow_color do
        begin
        graphics.DrawLine(pencil_vanille,left,top,pred(right),pred(bottom));
        graphics.DrawLine(pencil_vanille,pred(right),top,left,pred(bottom));
        end;
      pencil_vanille.free;
      graphics.free;
      end
    else
      begin
      with rect_allow_color do
        begin
        moveto(memdc,left,top);
        lineto(memdc,right,bottom);
        moveto(memdc,right,top);
        lineto(memdc,left,bottom);
        end;
      end;
    abrush:=selectobject(memdc,createsolidbrush(self.color_one));
    setrect(rect_color_one,40,270,62,290);
    with rect_color_one do  rectangle(memdc,left,top,right,bottom);
    deleteobject(selectobject(memdc,abrush));
    abrush:=selectobject(memdc,createsolidbrush(self.color_two));
    setrect(rect_color_two,70,270,92,290);
    with rect_color_two do rectangle(memdc,left,top,right,bottom);
    deleteobject(selectobject(memdc,abrush));
    end;
  {Plaquer l'image de la cachette sur la fenêtre}
  with arect do Bitblt(paintdc,0,0,right,bottom,memdc,0,0,SRCCOPY);
  deleteobject(selectobject(memdc,old_bitmap));
  deleteDC(memdc);
  windows.endpaint(self.hwindow,PaintStruct);
  wmain.Status_window.Show_time_during_of_operation(time_before);
  end; {TWin_animation.WMpaint}

procedure TWin_animation.Positionner_les_curseurs(var Msg: TMessage);
  var apoint:tpoint;
      another_rect:trect;
  begin
  apoint.x:=Smallint(loword(msg.lparam));
  apoint.y:=Smallint(hiword(msg.lparam));
  another_rect:=rect_repetition;
  dec(another_rect.right,10);
  {Just another  sofware compagnie}
  if ptinrect(another_rect,apoint) then
    begin
    self.count:=apoint.x-10;
    invalidaterect(self.hwindow,nil,false);
    end;
  another_rect:=rect_decalage;
  dec(another_rect.right,10);
  if ptinrect(another_rect,apoint) then
    begin
    self.offset:=apoint.x-10;
    invalidaterect(self.hwindow,nil,false);
    end;
  end; {TWin_animation.positionner_les_curseurs}

procedure TWin_animation.WMCommand(var Msg: Tmessage);
  begin {TWin_animation.WMCommand}
    inherited WMCommand(Msg);
    case LOWORD(msg.wparam) of
    Dial_champs.unit_timer_10_millisecondes:do_animation(10);
    Dial_champs.unit_timer_50_millisecondes:do_animation(50);
    Dial_champs.unit_timer_75_millisecondes:do_animation(75);
    Dial_champs.unit_timer_100_millisecondes:do_animation(100);
    Dial_champs.unit_timer_200_millisecondes:do_animation(200);
    Dial_champs.unit_timer_300_millisecondes:do_animation(300);
    Dial_champs.unit_timer_400_millisecondes:do_animation(400);
    Dial_champs.unit_timer_500_millisecondes:do_animation(500);
    Dial_champs.unit_timer_1000_millisecondes:do_animation(1000);
    Dial_champs.unit_timer_2000_millisecondes:do_animation(2000);
    Dial_champs.unit_timer_3000_millisecondes:do_animation(3000);
    Dial_champs.unit_timer_4000_millisecondes:do_animation(4000);
    Dial_champs.unit_timer_5000_millisecondes:do_animation(5000);
    Dial_champs.unit_timer_25_images_par_secondes:do_animation(40);
    Dial_champs.unit_timer_50_images_par_secondes:do_animation(20);
    end; {case}
  end; {TWin_animation.WMCommand}

const ks_nom_du_fichier_initial = 'temp\animation_raz.ato';

procedure TWin_animation.Memoriser_l_etat_initiale;
  var nom_du_fichier_temporaire:wutil.pc1024;
  begin
  wutil.get_exe_path(nom_du_fichier_temporaire);
  strcat(nom_du_fichier_temporaire,Unit_animation.ks_nom_du_fichier_initial);
  wmain.MainWindow.Sauvegarder_en_ATO(strpas(nom_du_fichier_temporaire),false,false,false);
  end;

procedure TWin_animation.Revenir_a_l_etat_initial;
  var nom_du_fichier_temporaire:wutil.pc1024;
  begin
  wutil.get_exe_path(nom_du_fichier_temporaire);
  strcat(nom_du_fichier_temporaire,Unit_animation.ks_nom_du_fichier_initial);
  wmain.MainWindow.Lecture_du_fichier(nom_du_fichier_temporaire);
  end;

procedure TWin_animation.do_animation(ellapse:integer);
  begin
  if not Self.timer_actif then
    begin
    Self.timer_actif:=True;
    Settimer(self.hwindow,kid_animation,ellapse,nil);
    invalidaterect(self.hwindow,nil,false);
    end;
  end; {TWin_animation.do_animation}

procedure TWin_animation.Make_animation;
  var i,j:integer;
      temp_file_transition:pc1024; {of caractères}
      calque_relatif:pc1024; {of caractères}
      pc_layer:pc1024; {of caractères}
      pc_index:pc20;
      un_calque_actif:col_plan.TCalque;
      un_index:u_object.tindex;
      an_element:u_object.tforme_color;
      error:boolean;
      flux_des_transitions:Classes.tfilestream;
      nb_repetition:integer;
      deplacement_offset:tpoint;
  begin
  un_calque_actif:=wmain.MainWindow.wmsg.col_dessin.Get_calque_actif;
  if un_Calque_actif=nil then begin bip; exit; end;
  wutil.get_exe_path(temp_file_transition);
  strcat(temp_file_transition,'temp\transition.ato');
  {Une itération de boucle pour faire varier la position d'un élément}
  if true then
    begin
    error:=False;
    flux_des_transitions:=tfilestream.Create(temp_file_transition,fmCreate);
    nb_repetition:=Self.count;
    deplacement_offset.x:=+round(cos(self.angle*pi/180)*relation._10mm_to_log_pouce(self.offset));
    deplacement_offset.y:=-round(sin(self.angle*pi/180)*relation._10mm_to_log_pouce(self.offset));
    for i:=1 to nb_repetition do
      begin
      inttopchar(i,pc_index);
      strcat(strcat(strcopy(calque_relatif,string_Transition),'_'),pc_index);
      strcat(strcat(strcopy(pc_layer,'Layer name="'),calque_relatif),'"'+CRLF);
      flux_des_transitions.WriteBuffer(pc_layer,strlen(pc_layer));
      for j:=0 to pred(un_Calque_actif.col_select.Count) do
        begin
        un_index:=un_Calque_actif.col_select.at(j);
        if un_index<>nil then
          begin
          an_element:=un_calque_actif.formindex(un_index);
          if an_element<>nil then
            begin
            an_element.deplace(i*deplacement_offset.x,i*deplacement_offset.y,0);
            if self.variation_des_couleurs then
              begin
              an_element.couleur_pinceau:=deformat.IN_Between_longint_RGB(self.color_one,self.color_two,i,nb_repetition);
              an_element.brush1.lbColor:=an_element.couleur_pinceau;
              end;
            an_element.Export_ato(flux_des_transitions,error,self.hwindow);
            an_element.deplace(-i*deplacement_offset.x,-i*deplacement_offset.y,0);
            end;
          end;
        end; {For j}
      end; {For i}
    flux_des_transitions.Free;
    end; {an_element<>nil}
  wmain.MainWindow.Lecture_du_fichier(temp_file_transition);
  end; {TWin_animation.Make_animation}

procedure TWin_animation.WMLButtonDown(var Msg: TMessage);
  var apoint,un_point_menu_popup:tpoint; un_menu_popup:hmenu;
  begin
  apoint.x:=Smallint(loword(msg.lparam));
  apoint.y:=Smallint(hiword(msg.lparam));
  self.down:=true;
  self.WMMOUSEMOVE(msg);
  self.Positionner_les_curseurs(Msg);
  if ptinrect(Unit_animation.rect_lancer_animation,apoint) then
    begin
    if self.timer_actif then
      begin
      self.timer_actif:=False;
      killtimer(self.hwindow,kid_animation);
      invalidaterect(self.hwindow,nil,false);
      invalidaterect(wmain.MainWindow.hwindow,nil,false);
      end
    else
      begin
      un_menu_popup:=CreatePopUpMenu;
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_10_millisecondes,'10 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_50_millisecondes,'50 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_75_millisecondes,'75 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_100_millisecondes,'100 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_200_millisecondes,'200 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_300_millisecondes,'300 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_400_millisecondes,'400 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_500_millisecondes,'500 millisecondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_1000_millisecondes,'Une seconde');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_2000_millisecondes,'Deux secondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_3000_millisecondes,'Trois secondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_4000_millisecondes,'Quatre secondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_5000_millisecondes,'Cinq secondes');
      Appendmenu(un_menu_popup,MF_SEPARATOR,0,nil);
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_25_images_par_secondes,'25 images par secondes');
      Appendmenu(un_menu_popup,MF_String,Dial_champs.unit_timer_50_images_par_secondes,'50 images par secondes');
      GetCursorPos(un_point_menu_popup);
      TrackPopupMenu(un_menu_popup,0,un_point_menu_popup.x,un_point_menu_popup.y,0,self.hwindow,nil);
      end;
    end
  else if ptinrect(rect_create_animation,apoint) then
    self.Make_animation
  else if ptinrect(rect_remise_a_zero,apoint) then
    self.Revenir_a_l_etat_initial
  else if ptinrect(rect_allow_color,apoint) then
    begin
    self.variation_des_couleurs:=not self.variation_des_couleurs;
    invalidaterect(self.hwindow,nil,false);
    end;
  end; {TWin_animation.WMLButtonDown}

procedure TWin_animation.WMLButtonUp(var Msg: TMessage);
  var apoint:tpoint;
      arect,arect_help:trect;
      my_color_picker:c_color.tw_color_surgissante;
  begin
  getclientrect(self.hwindow,arect);
  apoint.x:=Smallint(loword(msg.lparam));
  apoint.y:=Smallint(hiword(msg.lparam));
  self.down:=false;
  if ptinrect(rect_color_one,apoint) then
    begin
    color_one_picker:=true;
    color_two_picker:=false;
    my_color_picker:=c_color.tw_color_surgissante.Create(self,false,false);
    end
  else if ptinrect(rect_color_two,apoint) then
    begin
    color_one_picker:=false;
    color_two_picker:=true;
    my_color_picker:=c_color.tw_color_surgissante.Create(self,false,false);
    end;
  setrect(arect_help,arect.right-20,4,arect.right-4,20);
  if ptinrect(arect_help,apoint) then
    haide.aide_context_by_string('animation');
  end; {TWin_animation.WMLButtonUp}

procedure TWin_animation.WMMOUSEMOVE(var msg:tmessage);
  var apoint:tpoint;
      arect:trect;
      une_distance:real;
  begin
  if self.down then
    begin
    getclientrect(self.hwindow,arect);
    apoint.x:=Smallint(loword(msg.lparam));
	  apoint.y:=Smallint(hiword(msg.lparam));
    une_distance:=utile.distance(apoint.x,apoint.y,arect.right div 2,(arect.bottom-k_offset) div 2);
    if une_distance<69 then //année érotique et celle de colas
      begin
      self.angle:=round(angle_degree(arect.right div 2,(arect.bottom-k_offset) div 2,apoint.x,apoint.y));
      if (GetKeyState(VK_SHIFT)<0) then
        self.angle:=round(self.angle/15)*15
      else if (GetKeyState(VK_LCONTROL)<0) then
        self.angle:=round(self.angle/5)*5;
      invalidaterect(self.hwindow,nil,false);
      end;
    self.Positionner_les_curseurs(Msg);
    end; {touche down appuyée}
  invalidaterect(self.hwindow,nil,false);
  end; {TWin_animation.WMMOUSEMOVE-Denis B. le 10 septembre 2016}

procedure TWin_animation.WMTimer(var Msg: TMessage);
  begin
  if loword(msg.wparam)=kid_animation then
    self.Animation_des_calques;
  end; {TWin_animation.WMTimer}

procedure TWin_animation.Animation_des_calques;
  var i,isel:integer;
      un_calque:col_plan.TCalque;
      old_cursor:boolean;
  begin
  isel:=-1;
  //Détecter le calque actif et visible
  for i:=0 to pred(wmain.MainWindow.wmsg.col_dessin.list_calque.Count) do
    begin
    un_calque:=col_plan.TCalque(wmain.MainWindow.wmsg.col_dessin.list_calque.at(i));
    if (un_calque<>nil) and (un_calque.ClassType=col_plan.TCalque) then
      if un_calque.visible=1 then
        isel:=i;
    end;
  //Passer tous les calques à invisible
  for i:=0 to pred(wmain.MainWindow.wmsg.col_dessin.list_calque.Count) do
    begin
    un_calque:=col_plan.TCalque(wmain.MainWindow.wmsg.col_dessin.list_calque.at(i));
    if (un_calque<>nil) and (un_calque.ClassType=col_plan.TCalque) then
      un_calque.visible:=0;
    end;
  //Activer le calque suivant ou le premier calque si la boucle est terminée
  isel:=(succ(isel)) mod wmain.MainWindow.wmsg.col_dessin.list_calque.count;
  un_calque:=col_plan.TCalque(wmain.MainWindow.wmsg.col_dessin.list_calque.at(isel));
  if (un_calque<>nil) and (un_calque.ClassType=col_plan.TCalque) then
    un_calque.visible:=1;
  old_cursor:=wmain.MainWindow.bool_show_cursor_when_redraw;
  wmain.MainWindow.bool_show_cursor_when_redraw:=false;
  invalidaterect(wmain.MainWindow.hwindow,nil,false);
  updatewindow(wmain.MainWindow.hwindow);
  wmain.MainWindow.bool_show_cursor_when_redraw:=old_cursor;
  if (GetKeyState(vk_Control)<0)
  or (GetKeyState(vk_shift)<0) then
    begin
    sendmessage(wmain.MainWindow.hwindow,wm_selection_changer,0,0);
    end;
  end; {TWin_animation.Animation_des_calques}

procedure TWin_animation.WMClose(var msg:TMessage);
  begin
  if self.timer_actif then
    killtimer(self.hwindow,kid_animation);
  postmessage(wmain.MainWindow.hwindow,wm_selection_changer,0,0);
  inherited WMClose(msg);
  end;

procedure TWin_animation.WMSet_painture_control(var Msg: TMessage);
  begin
  if self.color_one_picker then
    self.color_one:=msg.LParam
  else if self.color_two_picker then
    self.color_two:=msg.LParam;
  invalidaterect(self.hwindow,nil,false);
  end; {TWin_animation.WMSet_painture_control}

end.


© Beelog
www.Denisdraw.fr