IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP Discussion :

Dégradé linéaire en asp


Sujet :

ASP

  1. #1
    Membre actif
    Homme Profil pro
    Webmaster Pays Basque
    Inscrit en
    Avril 2004
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France

    Informations professionnelles :
    Activité : Webmaster Pays Basque
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 207
    Points : 238
    Points
    238
    Par défaut Dégradé linéaire en asp
    Bonjour,
    J'ai besoin de créer un dégradé linéaire en fonction d'une couleur passé en paramètre, et tout ça en asp. J'ai bien trouvé des bouts de code en javascript masi rien au niveau asp.
    Je détaille :
    Je passe une couleur en paramètre dans une page enfant et le système me propose un choix de 20 couleurs dans un dégradé correspondant à ma couleur qui va de 000000 à FFFFFF, la couleur passée en paramètre se trouvant bien sur au milieu de mon dégradé.
    Si quelqu'un a un bout de code en suggestion, c'est avec plaisir.
    Merci

  2. #2
    Membre actif
    Homme Profil pro
    Webmaster Pays Basque
    Inscrit en
    Avril 2004
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France

    Informations professionnelles :
    Activité : Webmaster Pays Basque
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 207
    Points : 238
    Points
    238
    Par défaut
    Bon, ben je vois que ça n'attire pas grand monde...

    Comme ça ne m'empêche pas à continuer de bosser dessus, je vous colle le bout de code sur lequel j'ai travaillé.
    L'algo me permet de créer un dégradé du noir vers la couleur passée en paramètre mais pas au dela.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    <% colorHex=request("colorHex")
     
    Red = Cint("&H"& mid(colorHex,1,2))
    Green = Cint("&H"& mid(colorHex,3,2))
    Blue = Cint("&H"& mid(colorHex,5,2))
    ColorHexR = Red
    ColorHexG = Green
    ColorHexB = Blue
    colorHex = Red &"|"& Green &"|"& Blue
     
    color_end=split(colorHex,"|")
    color_beg = Array (0,0,0)
    color_end = Array (255,255,255)
    valu = Array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f")
     
    function genRanges()
    	color_end=split(colorHex,"|")
    	qty = 25
    	beg_col_1 = color_beg(0)
    	beg_col_2 = color_beg(1)
    	beg_col_3 = color_beg(2)
     
    	step1 = Cint((beg_col_1 - color_end(0)) / ((qty/2)-1))
    	step2 = Cint((beg_col_2 - color_end(1)) / ((qty/2)-1))
    	step3 = Cint((beg_col_3 - color_end(2)) / ((qty/2)-1))
     
     
    	for i = 1 to (qty/2)
    		bg_col = RGBtoColor(beg_col_1, beg_col_2, beg_col_3)
    		fg_col = RGBtoColor((beg_col_1 OR 255), (beg_col_2 OR 255), (beg_col_3 OR 255))
     
    		beg_col_1=beg_col_1-step1
    		beg_col_2=beg_col_2-step2
    		beg_col_3=beg_col_3-step3
     
    		response.write "<tr><td style='width:10px;'>"&i&"</td>"
    		response.write "<td onmouseout='mouseOutMap()' onclick='clickColor("""&bg_col&""",-1,-1)' onmouseover='mouseOverColor("""&bg_col&""")' style='width:200px;height:20px;color:#FFFFFF;background:"&bg_col&"'>&nbsp;</td>"
    		response.write "<td style='width:10px;'></td><td style='font-family:courier new;font-size:110%;'>"&bg_col&"</td></tr>"
     
    	next
     
    	color_beg = Array (beg_col_1-step1,beg_col_2-step2,beg_col_3-step3)
    	color_end = Array (255,255,255)
    	beg_col_1 = color_beg(0)
    	beg_col_2 = color_beg(1)
    	beg_col_3 = color_beg(2)
     
    	step1 = Cint((beg_col_1 - color_end(0)) / ((qty/2)-2))
    	step2 = Cint((beg_col_2 - color_end(1)) / ((qty/2)-2))
    	step3 = Cint((beg_col_3 - color_end(2)) / ((qty/2)-2))
     
     
    	for i = i to (qty-2)
    		bg_col = RGBtoColor(beg_col_1, beg_col_2, beg_col_3)
    		fg_col = RGBtoColor((beg_col_1 OR 255), (beg_col_2 OR 255), (beg_col_3 OR 255))
     
    		beg_col_1=beg_col_1-step1
    		beg_col_2=beg_col_2-step2
    		beg_col_3=beg_col_3-step3
     
    		response.write "<tr><td style='width:10px;'>"&i&"</td>"
    		response.write "<td onmouseout='mouseOutMap()' onclick='clickColor("""&bg_col&""",-1,-1)' onmouseover='mouseOverColor("""&bg_col&""")' style='width:200px;height:20px;color:#FFFFFF;background:"&bg_col&"'>&nbsp;</td>"
    		response.write "<td style='width:10px;'></td><td style='font-family:courier new;font-size:110%;'>"&bg_col&"</td></tr>"
    	next
     
    End function
     
    function Hex16(num)
    	if num > 15 then num = 15
    	if num < 0 then num = 0
    	Hex16 = (valu(num))
    end function
     
    function Hex16ToInt(digit)
    	Hex16ToInt=""
    	for i = 0 to ubound(valu)
    	      if digit=valu(i) then Hex16ToInt=i
    	next
    end function
     
    function Hex255(num)
    	if num > 255 then num = 255
    	if num < 0 then num = 0
    	Hex255 = Hex16(Cint(num / 16)) & Hex16(Cint(num mod 16))
    end function
     
    function Hex255ToInt(digit)
    	if len(digit)=1 then
    		Hex255ToInt=Hex16ToInt(digit)
    	elseif len(digit)>1 then
    		Hex255ToInt = Cint(Hex16ToInt(mid(digit,1,1)))*16 & Hex16ToInt(mid(digit,2,1))
    	else 
    		Hex255ToInt=NULL
    	end if
    end function
     
    function ColorToRGB(color)
    	rgb = Array (NULL, NULL, NULL)
    	if len(color)=7 then
    		rgb(0) = Hex255ToInt(mid(color,1,1)&mid(color,2,1))
    		rgb(1) = Hex255ToInt(mid(color,3,1)&mid(color,4,1))
    		rgb(2) = Hex255ToInt(mid(color,5,1)&mid(color,6,1))
    	end if
    	ColorToRGB=rgb
    end function
     
    function RGBtoColor(red, green, blue)
    	if red > 255 then red = 255
    	if green > 255 then green = 255
    	if blue > 255 then blue = 255
    	if red < 0 then red = 0
    	if green < 0 then green = 0
    	if blue < 0 then blue = 0
    	RGBtoColor="#" & Hex255(red) & Hex255(green) & Hex255(blue)
    end function%>
     
    <table cellpadding='0' cellspacing='0' border='0' style='margin-right:5px;'>
    <tr style='height:30px;'>
    	<td></td>
    	<td valign='top' align='left'>Darker/lighter shades:</td>
    	<td colspan='2' valign='top' align='left'>Hex values:</td>
    </tr>
    <% genRanges %>
    </table>
    Ce code est issu d'un javascript retranscrit en asp. C'est pas complètement satisfaisant mais c'est toujours un départ.

    Merci à ceux qui veulent bien y participer.

  3. #3
    Futur Membre du Club
    Homme Profil pro
    ASP Javascript Ajax Jquey
    Inscrit en
    Janvier 2011
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : ASP Javascript Ajax Jquey
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2011
    Messages : 5
    Points : 6
    Points
    6
    Par défaut
    Replace ton code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    for i = i to (qty-2)
    		bg_col = RGBtoColor(beg_col_1, beg_col_2, beg_col_3)
    		fg_col = RGBtoColor((beg_col_1 OR 255), (beg_col_2 OR 255), (beg_col_3 OR 255))
     
    		beg_col_1=beg_col_1-step1
    		beg_col_2=beg_col_2-step2
    		beg_col_3=beg_col_3-step3
     
    		response.write "<tr><td style='width:10px;'>"&i&"</td>"
    		response.write "<td onmouseout='mouseOutMap()' onclick='clickColor("""&bg_col&""",-1,-1)' onmouseover='mouseOverColor("""&bg_col&""")' style='width:200px;height:20px;color:#FFFFFF;background:"&bg_col&"'>&nbsp;</td>"
    		response.write "<td style='width:10px;'></td><td style='font-family:courier new;font-size:110%;'>"&bg_col&"</td></tr>"
    	next

    Par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
     
    for i = i to (qty-2)
     
    		if cdbl(replace(bg_col, "#", "&H")) < cdbl("&H"&request("colorHex")) then 
    			response.Write(bg_col)
     
    			bg_col = RGBtoColor(beg_col_1, beg_col_2, beg_col_3)
    			fg_col = RGBtoColor((beg_col_1 OR 255), (beg_col_2 OR 255), (beg_col_3 OR 255))
     
    			beg_col_1=beg_col_1-step1
    			beg_col_2=beg_col_2-step2
    			beg_col_3=beg_col_3-step3
     
    			response.write "<tr><td style='width:10px;'>"&i&"</td>"
    			response.write "<td onmouseout='mouseOutMap()' onclick='clickColor("""&bg_col&""",-1,-1)' onmouseover='mouseOverColor("""&bg_col&""")' style='width:200px;height:20px;color:#FFFFFF;background:"&bg_col&"'>&nbsp;</td>"
    			response.write "<td style='width:10px;'></td><td style='font-family:courier new;font-size:110%;'>"&bg_col&"</td></tr>"
    		end if
    	next

  4. #4
    Membre actif
    Homme Profil pro
    Webmaster Pays Basque
    Inscrit en
    Avril 2004
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France

    Informations professionnelles :
    Activité : Webmaster Pays Basque
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 207
    Points : 238
    Points
    238
    Par défaut
    Déjà merci d'avoir répondu.
    Mais ne semble pas marcher, à prioiri à un soucis avec la comparaison en cdbl
    Plus précisemment, c'est le
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    cdbl(replace(bg_col, "#", "&H"))
    qui ne lui plait pas

  5. #5
    Futur Membre du Club
    Homme Profil pro
    ASP Javascript Ajax Jquey
    Inscrit en
    Janvier 2011
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : ASP Javascript Ajax Jquey
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2011
    Messages : 5
    Points : 6
    Points
    6
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    response.Write cdbl("&Hffffff")
    Resultat : 16777215

    Bizard surtout que j'ai fais le test complet sur une mon server



    index.asp?colorHex=4881be
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    <% colorHex=request("colorHex")
     
    Red = cdbl("&H"& mid(colorHex,1,2))
    Green = cdbl("&H"& mid(colorHex,3,2))
    Blue = cdbl("&H"& mid(colorHex,5,2))
    ColorHexR = Red
    ColorHexG = Green
    ColorHexB = Blue
    colorHex = Red &"|"& Green &"|"& Blue
     
    color_end=split(colorHex,"|")
    color_beg = Array (0,0,0)
    color_end = Array (255,255,255)
    valu = Array ("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f")
     
    function genRanges()
    	color_end=split(colorHex,"|")
    	qty = 25
    	beg_col_1 = color_beg(0)
    	beg_col_2 = color_beg(1)
    	beg_col_3 = color_beg(2)
     
    	step1 = Cint((beg_col_1 - color_end(0)) / ((qty/2)-1))
    	step2 = Cint((beg_col_2 - color_end(1)) / ((qty/2)-1))
    	step3 = Cint((beg_col_3 - color_end(2)) / ((qty/2)-1))
     
     
    	for i = 1 to (qty/2)
    		bg_col = RGBtoColor(beg_col_1, beg_col_2, beg_col_3)
    		fg_col = RGBtoColor((beg_col_1 OR 255), (beg_col_2 OR 255), (beg_col_3 OR 255))
     
    		beg_col_1=beg_col_1-step1
    		beg_col_2=beg_col_2-step2
    		beg_col_3=beg_col_3-step3
     
    		response.write "<tr><td style='width:10px;'>"&i&"</td>"
    		response.write "<td onmouseout='mouseOutMap()' onclick='clickColor("""&bg_col&""",-1,-1)' onmouseover='mouseOverColor("""&bg_col&""")' style='width:200px;height:20px;color:#FFFFFF;background:"&bg_col&"'>&nbsp;</td>"
    		response.write "<td style='width:10px;'></td><td style='font-family:courier new;font-size:110%;'>"&bg_col&"</td></tr>"
     
    	next
     
    	color_beg = Array (beg_col_1-step1,beg_col_2-step2,beg_col_3-step3)
    	color_end = Array (255,255,255)
    	beg_col_1 = color_beg(0)
    	beg_col_2 = color_beg(1)
    	beg_col_3 = color_beg(2)
     
    	step1 = Cint((beg_col_1 - color_end(0)) / ((qty/2)-2))
    	step2 = Cint((beg_col_2 - color_end(1)) / ((qty/2)-2))
    	step3 = Cint((beg_col_3 - color_end(2)) / ((qty/2)-2))
     
     
    	for i = i to (qty-2)
     
    		if cdbl(replace(bg_col, "#", "&H")) < cdbl("&H"&request("colorHex")) then 
    			response.Write(bg_col)
     
    			bg_col = RGBtoColor(beg_col_1, beg_col_2, beg_col_3)
    			fg_col = RGBtoColor((beg_col_1 OR 255), (beg_col_2 OR 255), (beg_col_3 OR 255))
     
    			beg_col_1=beg_col_1-step1
    			beg_col_2=beg_col_2-step2
    			beg_col_3=beg_col_3-step3
     
    			response.write "<tr><td style='width:10px;'>"&i&"</td>"
    			response.write "<td onmouseout='mouseOutMap()' onclick='clickColor("""&bg_col&""",-1,-1)' onmouseover='mouseOverColor("""&bg_col&""")' style='width:200px;height:20px;color:#FFFFFF;background:"&bg_col&"'>&nbsp;</td>"
    			response.write "<td style='width:10px;'></td><td style='font-family:courier new;font-size:110%;'>"&bg_col&"</td></tr>"
    		end if
    	next
     
     
    End function
     
    function Hex16(num)
    	if num > 15 then num = 15
    	if num < 0 then num = 0
    	Hex16 = (valu(num))
    end function
     
    function Hex16ToInt(digit)
    	Hex16ToInt=""
    	for i = 0 to ubound(valu)
    	      if digit=valu(i) then Hex16ToInt=i
    	next
    end function
     
    function Hex255(num)
    	if num > 255 then num = 255
    	if num < 0 then num = 0
    	Hex255 = Hex16(Cint(num / 16)) & Hex16(Cint(num mod 16))
    end function
     
    function Hex255ToInt(digit)
    	if len(digit)=1 then
    		Hex255ToInt=Hex16ToInt(digit)
    	elseif len(digit)>1 then
    		Hex255ToInt = Cint(Hex16ToInt(mid(digit,1,1)))*16 & Hex16ToInt(mid(digit,2,1))
    	else 
    		Hex255ToInt=NULL
    	end if
    end function
     
    function ColorToRGB(color)
    	rgb = Array (NULL, NULL, NULL)
    	if len(color)=7 then
    		rgb(0) = Hex255ToInt(mid(color,1,1)&mid(color,2,1))
    		rgb(1) = Hex255ToInt(mid(color,3,1)&mid(color,4,1))
    		rgb(2) = Hex255ToInt(mid(color,5,1)&mid(color,6,1))
    	end if
    	ColorToRGB=rgb
    end function
     
    function RGBtoColor(red, green, blue)
    	if red > 255 then red = 255
    	if green > 255 then green = 255
    	if blue > 255 then blue = 255
    	if red < 0 then red = 0
    	if green < 0 then green = 0
    	if blue < 0 then blue = 0
    	RGBtoColor="#" & Hex255(red) & Hex255(green) & Hex255(blue)
    end function%>
     
    <table cellpadding='0' cellspacing='0' border='0' style='margin-right:5px;'>
    <tr style='height:30px;'>
    	<td></td>
    	<td valign='top' align='left'>Darker/lighter shades:</td>
    	<td colspan='2' valign='top' align='left'>Hex values:</td>
    </tr>
    <% genRanges %>
    </table>

  6. #6
    Membre actif
    Homme Profil pro
    Webmaster Pays Basque
    Inscrit en
    Avril 2004
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France

    Informations professionnelles :
    Activité : Webmaster Pays Basque
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 207
    Points : 238
    Points
    238
    Par défaut
    Alors oui, effectivement ton code marche... je n'ai pas encore compris pourquoi je n'ai pas réussi à le faire marcher la première fois, il va falloir que je l'analyse pour trouver ma faille...
    Ceci étant, ta modification ne répond pas complètement à ma question. Il faudrait que le dégradé aille du noir au blanc en 21 étapes, 10 avant, 10 après, la couleur sélectionnée en position 11.
    Ton code, comme le mien précédemment, part bien du noir mais ne va pas jusqu'au blanc.
    Une idée ?

  7. #7
    Membre actif
    Homme Profil pro
    Webmaster Pays Basque
    Inscrit en
    Avril 2004
    Messages
    207
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France

    Informations professionnelles :
    Activité : Webmaster Pays Basque
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2004
    Messages : 207
    Points : 238
    Points
    238
    Par défaut
    Je fais remonter le sujet parce que
    - 1 : il n'est pas clos
    - 2 : je me suis aperçu d'une erreur dans ce que je voulais faire

    J'ai confondu dégradé de couleur et dégradé de lumière.
    Si grossièrement, j'ai bien réussi avec mon code et les modifs fournies par tayoze à gaire fonctionner le dégradé, je n'ai pas réussi à obtenir ce que je voulais. Et pour cause donc, puisque ce que je cherche à obtenir n'est pas un dégradé de couleur (qui va du noir au blanc suivant une couleur choisie) mais bien un dégradé de lumière !!
    Du coup, j'ai fouillé un peu pour corriger tout ça et découvrir les 2 univers RGB et HSL. mais pas de code en asp ou vb. du coup je suis un peu coincé.
    Si quelqu'un a une idée ? Merci

Discussions similaires

  1. [CSS 3] Dégradé linéaire pour Opera et Firefox
    Par badrou dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 29/07/2011, 12h16
  2. Dégradé non linéaire
    Par metacoders dans le forum OpenGL
    Réponses: 3
    Dernier message: 07/04/2008, 19h20
  3. dègradé linéaire dans un tableau
    Par H-bil dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 25/05/2006, 15h50
  4. [CR][ASP] interfaçage
    Par grosjej dans le forum SAP Crystal Reports
    Réponses: 2
    Dernier message: 15/04/2004, 10h20
  5. Erreur fréquente avec ASP et IIS
    Par Community Management dans le forum ASP
    Réponses: 2
    Dernier message: 11/02/2004, 22h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo