Add(InlineCode,8666069,322,329) { @Hint=#10:HSL >> RGB| WorkPoints=#9:doHSL2RGB| EventPoints=#6:outRGB| VarPoints=#1:R|1:G|1:B| DataPoints=#1:H|1:S|1:L| Code=#15:unit HiAsmUnit;|0:|9:interface|13://by Login :)|29:uses Windows,kol,Share,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|17: rR,rG,rB:byte;|9: public|20: outRGB:THI_Event;|15: H:THI_Event;|15: S:THI_Event;|15: L:THI_Event;|3: |54: procedure doHSL2RGB(var Data:TData; index:word); |43: procedure R(var Data:TData; index:word);|43: procedure G(var Data:TData; index:word);|43: procedure B(var Data:TData; index:word);|51: function Hue_2_RGB(var v1, v2, vH :double):byte;|3: |5: end;|0:|14:implementation|0:|20://Function Hue_2_RGB|31:function THiAsmClass.Hue_2_RGB;|13: |5:begin|40: if ( vH < 0 ) then vH := vH + 1; |36: if ( vH > 1 ) then vH := vH - 1;|7: |30: if ( ( 6 * vH ) < 1 ) then|10: begin |55: result := Round(( v1 + ( v2 - v1 ) * 6 * vH )*255);|10: Exit; |8: end;|4: |30: if ( ( 2 * vH ) < 1 ) then|10: begin |30: result := Round(v2*255) ;|9: Exit;|8: end;|8: |30: if ( ( 3 * vH ) < 2 ) then|9: begin|72: result := Round(( v1 + ( v2 - v1 ) * ( 0.6666666 - vH ) * 6 )*255);|9: Exit;|12: end; |4: |28: result := Round(v1*255);|4:end;|0:|32:procedure THiAsmClass.doHSL2RGB;|39:var rH, rS, rL, var1, var2,Temp:double;|5:begin|28:rH := toIntegerEvent(H)/240;|28:rS := toIntegerEvent(S)/240;|28:rL := toIntegerEvent(L)/240;|0:|0:|61:if ( rS = 0 ) then //HSL from 0 to 1|9: begin|68: rR := Round(rL*255); //RGB results from 0 to 255|27: rG := Round(rL*255);|27: rB := Round(rL*255);|7: end|4:else|9: begin|92: if ( rL < 0.5 ) then var2 := rL * ( 1 + rS ) else var2 := ( rL + rS ) - ( rS * rL );|34: var1 := 2 * rL - var2; |31: Temp := rH + 0.3333333;|46: rR := Hue_2_RGB( var1, var2, Temp ); |42: rG := Hue_2_RGB( var1, var2, rH );|31: Temp := rH - 0.3333333;|48: rB := Hue_2_RGB( var1, var2, Temp ); |8: end;|8: |46: _hi_OnEvent(outRGB, RGB(rR,rG,rB)); |4:end;|0:|14://нижние точки|52:procedure THiAsmClass.R(var Data:TData; index:word);|5:begin|22: dtInteger(Data, rR);|4:end;|0:|52:procedure THiAsmClass.G(var Data:TData; index:word);|5:begin|22: dtInteger(Data, rG);|4:end;|0:|52:procedure THiAsmClass.B(var Data:TData; index:word);|5:begin|22: dtInteger(Data, rB);|4:end;|0:|0:|4:end.| AddHint(-27,-40,77,13,@Hint) }