>Colores por cada letra de un texto

>Colores por cada letra de un texto

Postby Willi Quintana » Sat Aug 09, 2014 4:03 pm

User avatar
Willi Quintana
 
Posts: 998
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: >Colores por cada letra de un texto

Postby Willi Quintana » Wed Aug 13, 2014 2:42 am

No es posible????
User avatar
Willi Quintana
 
Posts: 998
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: >Colores por cada letra de un texto

Postby Armando » Wed Aug 13, 2014 2:47 am

Willi:

Me parece que no existe una función para tal efecto, se me ocurre que metas el texto en
un array y ahí asignarle el color a cada letra. Solo una idea.

Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3049
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: >Colores por cada letra de un texto

Postby pgfdz » Wed Aug 13, 2014 7:46 am

Hola. A ver si esto te vale.
Un saludo


#include "fivewin.ch"


static oWnd

function main()

DEFINE WINDOW oWnd

ACTIVATE WINDOW oWnd ON PAINT Pinta( hDC )

return nil


function Pinta( hDC )

local nColor
local nLeft := 10
local cTexto := "En un lugar de la mancha de cuyo nombre no quiero acordarme"
local oFont
local hFont
local nLen := len( cTexto )
local cLetra, n

DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0, -18


hFont := SelectObject( hDC, oFont:hFont )


for n := 1 to nLen

cLetra := substr( cTexto, n, 1 )

nColor := SetTextColor( hDC, nRandom( CLR_WHITE ) )

TextOut( hDC, 10, nLeft, cLetra )

SetTextColor( hDC, nColor )

nLeft += GetTextWidth( hDC, cLetra, oFont )

next

SelectObject( hDC, hFont )

oFont:ENd()

return nil
Paco García
pgfdz
 
Posts: 145
Joined: Wed Nov 03, 2010 9:16 am

Re: >Colores por cada letra de un texto

Postby Carles » Wed Aug 13, 2014 8:18 am

Image
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1082
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: >Colores por cada letra de un texto

Postby karinha » Tue Mar 31, 2020 12:00 pm

Very good Paco.

Code: Select all  Expand view

#Include "Fivewin.ch"

STATIC oWnd

FUNCTION Main()

   DEFINE WINDOW oWnd

   ACTIVATE WINDOW oWnd MAXIMIZED ON PAINT Pinta( hDC )

RETURN NIL

FUNCTION Pinta( hDC )

   LOCAL nColor
   LOCAL nLeft  := 80
   LOCAL nRight := 220
   LOCAL cTexto := "AMBIENTE PAISAGISMO"
   LOCAL oFont
   LOCAL hFont
   LOCAL nLen := len( cTexto )
   LOCAL cLetra, n

   LOCAL nResHoriz, nResVert

   nResHoriz := oWnd:nHorzRes()
   nResVert  := oWnd:nVertRes()

   // Necesito más sugerencias para resoluciones de video.
   // I need more suggestions for video resolutions.
   IF nResHoriz = 1366 .AND. nResVert = 768

      nLeft  := 260
      nRight := 230

   ELSEIF nResHoriz = 1360 .AND. nResVert = 768

      nLeft  := 210
      nRight := 250

   ELSEIF nResHoriz = 1280 .AND. nResVert = 768

      nLeft  := 210
      nRight := 250

   ELSEIF nResHoriz = 1280 .AND. nResVert = 720

      nLeft  := 200
      nRight := 200

   ELSEIF nResHoriz = 1024 .AND. nResVert = 768  // Minha Maquina

      nLeft  :=  80
      nRight := 220

   ELSE

      nLeft  :=  80
      nRight := 220

   ENDIF

   // DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0, - 50
   DEFINE FONT oFont NAME "Segoe UI Symbol" SIZE 0, - 80

   hFont := SelectObject( hDC, oFont:hFont )

   FOR n := 1 TO nLen

      cLetra := substr( cTexto, n, 1 )

      nColor := SetTextColor( hDC, nRandom( CLR_HGREEN ) )  // COLORS.CH

      // TextOut( hDC, 10, nLeft, cLetra )
      TextOut( hDC, 325, nLeft, cLetra )

      SetTextColor( hDC, nColor )

      nLeft += GetTextWidth( hDC, cLetra, oFont )

   NEXT

   SelectObject( hDC, hFont )

   oFont:ENd()

RETURN NIL
 


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7151
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 10 guests