License GNU General Public License, version 2
Lines 80
Keywords
colourlovers (1) palette (1) sdlbasic (1)
Permissions
Owner: nitrofurano
Group Owner: sdlBasic
Viewable by Everyone
Editable by All Siafoo Users
Hide
Meet people who work on similar things as you – get help if you need it Join Siafoo Now or Learn More

creates a palette catalog (for a .cbz eBook) from colourlovers.com webpage Atom Feed 0

# 's
 1#! /usr/bin/sdlbrt
2#- creates a palette catalog (for a .cbz eBook) from colourlovers.com webpage - Paulo Silva - GPL license
3#- needs imagemagick and wget installed - only tested on Linux
4in_v=572000:fi_v=579000:xed=6*8*10+8+32+88:yed=8*100+48
5setdisplay(xed,yed,32,1):paper(0xFFFFFF):ink(0):pen(0):cls
6function hexvl(a$)
7 e=asc(ucase$(a$)):hexvl=abs(((e>=48 and e<=57)*(e-48))+((e>=65 and e<=70)*(e-55)))
8 end function
9 dim z$[255]:for i=0 to 255:z$[i]="55aa55aa55aa55aa":next
10z$[32]="0000000000000000":z$[33]="0010101010001000":z$[34]="0024240000000000":z$[35]="00247e24247e2400"
11 z$[36]="00083e283e0a3e08":z$[37]="0062640810264600":z$[38]="001028102a443a00":z$[39]="0008100000000000"
12 z$[40]="0004080808080400":z$[41]="0020101010102000":z$[42]="000014083e081400":z$[43]="000008083e080800"
13 z$[44]="0000000000080810":z$[45]="000000003e000000":z$[46]="0000000000181800":z$[47]="0000020408102000"
14 z$[48]="001e232529311e00":z$[49]="000c140404041f00":z$[50]="001e21011e203f00":z$[51]="001e210601211e00"
15 z$[52]="00040c14243f0400":z$[53]="003f203e01211e00":z$[54]="001e203e21211e00":z$[55]="003f010204080800"
16 z$[56]="001e211e21211e00":z$[57]="001e21211f011e00":z$[58]="0000000800000800":z$[59]="0000080000080810"
17 z$[60]="0000020408040200":z$[61]="0000001f001f0000":z$[62]="0000080402040800":z$[63]="001e210204000400"
18 z$[64]="003c4a565e403c00":z$[65]="003c42427e424200":z$[66]="007c427c42427c00":z$[67]="003c424040423c00"
19 z$[68]="0078444242447800":z$[69]="007e407c40407e00":z$[70]="007e407c40404000":z$[71]="003c42404e423c00"
20 z$[72]="0042427e42424200":z$[73]="003e080808083e00":z$[74]="0002020242423c00":z$[75]="0044487048444200"
21 z$[76]="0040404040407e00":z$[77]="0042665a42424200":z$[78]="004262524a464200":z$[79]="003c424242423c00"
22 z$[80]="007c42427c404000":z$[81]="003c4242524a3c00":z$[82]="007c42427c444200":z$[83]="003c403c02423c00"
23 z$[84]="00fe101010101000":z$[85]="0042424242423c00":z$[86]="0042424242241800":z$[87]="00424242425a2400"
24 z$[88]="0042241818244200":z$[89]="0082442810101000":z$[90]="007e040810207e00":z$[91]="000e080808080e00"
25 z$[92]="0000402010080400":z$[93]="0070101010107000":z$[94]="0010385410101000":z$[95]="00000000000000ff"
26 z$[96]="001c227820207e00":z$[97]="000038043c443c00":z$[98]="0020203c22223c00":z$[99]="00001c2020201c00"
27 z$[100]="0004043c44443c00":z$[101]="0000384478403c00":z$[102]="000c101810101000":z$[103]="00003c44443c0438"
28 z$[104]="0040407844444400":z$[105]="0010003010103800":z$[106]="0004000404042418":z$[107]="0020283030282400"
29 z$[108]="0010101010100c00":z$[109]="0000685454545400":z$[110]="0000784444444400":z$[111]="0000384444443800"
30 z$[112]="0000784444784040":z$[113]="00003c44443c0406":z$[114]="00001c2020202000":z$[115]="0000384038047800"
31 z$[116]="0010381010100c00":z$[117]="0000444444443800":z$[118]="0000444428281000":z$[119]="0000445454542800"
32 z$[120]="0000442810284400":z$[121]="00004444443c0438":z$[122]="00007c0810207c00":z$[123]="000e083008080e00"
33 z$[124]="0008080808080800":z$[125]="0070100c10107000":z$[126]="0014280000000000":z$[127]="3c4299a1a199423c"
34function bytefromhexdump(a$,byteadr)
35 i=(byteadr*2)+1:m1$=mid$(a$,i,1):m2$=mid$(a$,i+1,1):tmpr=(hexvl(m1$)*16)+hexvl(m2$):bytefromhexdump=tmpr
36 end function
37sub HexdumpPlot(x,y,a$,i,p)
38 for e=0 to (len(a$)/2)-1:v=bytefromhexdump(a$,e)
39 for z=0 to 7:ik=p:z2=7-z
40 if (((int(v/(2^z2)))mod 2) and (2^z2)) then:ik=i:end if
41 ink(ik):dot(x+z,y+e):next:next
42 end sub
43sub printsbl(a$,xl,yl)
44 alen=len(a$)
45 for iz=1 to alen
46 hx$=z$[asc(mid$(a$,iz,1))]:HexdumpPlot(xl*8,yl*8,hx$,pen,paper):xl=xl+1
47 if xl>((displaywidth\8)-1) then:xl=0:yl=yl+1:end if:next
48 end sub
49for lc=in_v to fi_v step 1000:cls
50printsbl(right$("000000"+str$(lc),6),65,1)
51for x=0 to 9: printsbl(right$("000"+str$(x*100),3),14+(x*6),3):next
52for y=0 to 99:printsbl(right$("000"+str$(y),2) ,9,y+4):next
53for x=0 to 9
54 for y=0 to 99
55 fl=lc+y+(x*100):p4$=str$(fl)
56 shell("wget http://www.colourlovers.com/export/html/"+p4$):shell("mv "+p4$+" _t_01.txt")
57 shell("cat _t_01.txt | grep Hex | sed 's/[ \\t]*//g;s/Hex://g' > _t_02.txt")
58 if fileexists("_t_02.txt")<>0 then
59 open "_t_02.txt" for input as #1
60 for x2=0 to 4
61 if eof(1)=0 then:
62 file input #1,txq$
63 rv= hexvl(mid$(txq$,2,1))*16+hexvl(mid$(txq$,3,1))
64 gv= hexvl(mid$(txq$,4,1))*16+hexvl(mid$(txq$,5,1))
65 bv= hexvl(mid$(txq$,6,1))*16+hexvl(mid$(txq$,7,1))
66 else:
67 rv=255:gv=255:bv=255
68 end if
69 ink(rgb(rv,gv,bv)):bar((x2+(x*6))*8+8+32+56,y*8+1+32,(x2+(x*6))*8+8+7+32+56,y*8+6+32 )
70 next
71 close #1
72 else:
73 for x2=0 to 4
74 rv=255:gv=255:bv=255:ink(rgb(rv,gv,bv)):bar((x2+(x*6))*8+8+32+56,y*8+1+32,(x2+(x*6))*8+8+7+32+56,y*8+6+32 )
75 next
76 end if
77 shell("rm _t_*.txt")
78 next:next
79grab(1,0,0,xed,yed):saveimage("pic.bmp",1):shell("convert pic.bmp pic"+str$(lc)+".png"):shell("rm pic.bmp")
80next