Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-06-2006
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Poder: 24
seoane Va por buen camino
Crear gradiente Tono / Saturacion

Código Delphi [-]
// B = Brillo (0..255)
procedure Gradiente(Canvas: TCanvas; R: TRect; b: integer);
var
  h,s: integer; // Tono, Saturacion, Luminosidad
  i,j: integer;
  x,y,z: integer;
  Bitmap: TBitmap;
begin
  Bitmap:= TBitmap.Create;
  try
    Bitmap.Width:= 360;
    Bitmap.Height:= 256;
    with Bitmap.Canvas do
      begin
        Brush.Color:= clBlack;
        FillRect(ClipRect);
        for h:= 0 to 359 do
          begin
            i:= ((h mod 60) * b) div 60;
            j:= b - i;
            for s:= 0 to 255 do
              begin
                x:= i + ((b-i) * s) div 255;
                y:= j + ((b-j) * s) div 255;
                z:= (b * s) div 255;
                case (h div 60) of
                  0: Pixels[h,s]:= RGB(b,x,z);
                  1: Pixels[h,s]:= RGB(y,b,z);
                  2: Pixels[h,s]:= RGB(z,b,x);
                  3: Pixels[h,s]:= RGB(z,y,b);
                  4: Pixels[h,s]:= RGB(x,z,b);
                  5: Pixels[h,s]:= RGB(b,z,y);
                end;
              end;
          end;
      end;
    Canvas.StretchDraw(R,Bitmap);
  finally
    Bitmap.Free;
  end;
end;

Ejemplos de uso:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  // Dibujamos el gradiente en el fondo del formulario
  Gradiente(Canvas,Rect(0,0,width,height),255);
end;

Código Delphi [-]
begin
  // Creamos un gradiente y lo guardamos en un bmp
  with TBitmap.Create do
  try
    Width:= 360;
    Height:= 256;
    Gradiente(Canvas,Canvas.ClipRect,255);
    SaveToFile('d:\gradiente.bmp');
  finally
    Free;
  end;
end;
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 16:36:33.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi