This block does not support .jpg format, is there a way to make it so?
| img newC | t1_t1 asString. (t1 asLowercase endsWith: '.gif') ifTrue: [ img _ (GIFReadWriter new setStream: (HTTPSocket httpGet: t1)) nextImage.] ifFalse: [ (t1 asLowercase endsWith: '.png') ifTrue: [ img _ (PNGReadWriter createAFormFrom: (HTTPSocket httpGet: t1) contents) first] ifFalse: [ img _ HTTPSocket httpJpeg: t1]]. newC _ ImageMedia new form: img; mediaName: (self unusedMediaNameFromBaseName: (self defaultImageMedia mediaName)). self addMediaItem: newC.
Offline
sparks wrote:
This block does not support .jpg format, is there a way to make it so?
Code:
| img newC | t1_t1 asString. (t1 asLowercase endsWith: '.gif') ifTrue: [ img _ (GIFReadWriter new setStream: (HTTPSocket httpGet: t1)) nextImage.] ifFalse: [ (t1 asLowercase endsWith: '.png') ifTrue: [ img _ (PNGReadWriter createAFormFrom: (HTTPSocket httpGet: t1) contents) first] ifFalse: [ img _ HTTPSocket httpJpeg: t1]]. newC _ ImageMedia new form: img; mediaName: (self unusedMediaNameFromBaseName: (self defaultImageMedia mediaName)). self addMediaItem: newC.
By the looks of it, it does as when it gets false for both ending with .gif and .png it assumes its a jpg (by the looks of it through my untrained eye)
Offline
sparks wrote:
No, it assumes it JPEG not JPG. That's the problem All the images I want to access happen to be JPG which is the only format not supported here.
Err... JPG and JPEG are the same format, the only reason why they use jpg is because it's 3 characters long and fits perfectly as a file extension JPEG stands for joint picture experts group (I think).
Also, see this if you still don't understand http://en.wikipedia.org/wiki/JPEG
Offline
RUMCHEERYPOOPOO wrote:
sparks wrote:
No, it assumes it JPEG not JPG. That's the problem All the images I want to access happen to be JPG which is the only format not supported here.
Err... JPG and JPEG are the same format, the only reason why they use jpg is because it's 3 characters long and fits perfectly as a file extension JPEG stands for joint picture experts group (I think).
Also, see this if you still don't understand http://en.wikipedia.org/wiki/JPEG
Well it's not importing JPG, that's all I know
Offline
sparks wrote:
RUMCHEERYPOOPOO wrote:
sparks wrote:
No, it assumes it JPEG not JPG. That's the problem All the images I want to access happen to be JPG which is the only format not supported here.
Err... JPG and JPEG are the same format, the only reason why they use jpg is because it's 3 characters long and fits perfectly as a file extension JPEG stands for joint picture experts group (I think).
Also, see this if you still don't understand http://en.wikipedia.org/wiki/JPEGWell it's not importing JPG, that's all I know
Strange... well I'm no squeak/smalltalk expert, leave it to the pros I say
Offline
scimonster wrote:
Greenatic wrote:
scimonster wrote:
The second biggest was the one before the most recent: 26 blocks!No, what I mean is, when are you going to do this gigantic update you mentioned? You're really confusing me...
No-one said anything about a gigantic update.
Librarians, could someone do the update?
OK, I'm confused. I thought you said you were about to do "the second biggest update in the history of the Library" or something like that...
Offline
YourLocalBlockLib wrote:
To install a block importer in Scratch to automatically add a (downloadable) block for you, click here! But beware, this feature is untested and does not currently work!
There is something wrong here, it is untested yet we know it doesn't work? We did test it. Otherwise we wouldn't know.
Offline
Pecola1 wrote:
YourLocalBlockLib wrote:
To install a block importer in Scratch to automatically add a (downloadable) block for you, click here! But beware, this feature is untested and does not currently work!
There is something wrong here, it is untested yet we know it doesn't work? We did test it. Otherwise we wouldn't know.
*adds to mental list of things to fix next week*
Offline
scimonster wrote:
Pecola1 wrote:
YourLocalBlockLib wrote:
To install a block importer in Scratch to automatically add a (downloadable) block for you, click here! But beware, this feature is untested and does not currently work!
There is something wrong here, it is untested yet we know it doesn't work? We did test it. Otherwise we wouldn't know.
*adds to mental list of things to fix next week*
lol, Can someone else do an update besides Scimonster?
Offline
Meowmeow, I can't go to the block upload page without it logging me out. Do you know why?
Greenatic wrote:
lol, Can someone else do an update besides Scimonster?
I do BYOB updates. I fact I have a two new blocks...
Sidharth wrote:
I have a nice BYOB block that I think you do not already have:
http://i.imgur.com/FpG60.gif
.ysp file is here. (mediafire download link page)
I don't see your block in the download...
Last edited by SSBBM (2011-07-28 14:44:51)
Offline
You can do Scratch too! Just follow the code format. If it's not too large I might take the effort to fix it.
Offline
SSBBM wrote:
Greenatic wrote:
lol, Can someone else do an update besides Scimonster?
I do BYOB updates. I fact I have a two new blocks...
Yeah, I just realized that sounded kinda mean. I'm really sorry.
On a more constructive-sounding note, it does seem that only Scimonster is doing Scratch updates, which is what I was refering to. Thing is, I'm about to upload an outrageous amount of blocks, which will allow you [mathematical crazy talk]to perform all Scratch numerical operations on any real integer in any real integer base from -36 to 36, with the exception of bases 0 and -1, since they do not exist.[/mathematical crazy talk].
Sorry, I had to say that.
Offline
.
BYOB Blocks added: 3
by SSBBM
by SSBBM
by SSBBM Does not change text in BYOB. It only adds BBCode tags. Considered one block in the statistics
Update carried out by block librarian: SSBBM
________________________________________________________________________________
^home
^updates archive
Offline
OK, here's the mega-block share I promised. These will support numerical operations with any real integer in any real integer base -36 to 36, except 0 and -1 since they aren't possible bases.
These took FOREVER to make! (well, actually, a week of occasional work )
NOTE: It's best to install all of these blocks at once.
ANOTHER NOTE: I know that I used string arguments for operations in other bases. Had I not used string arguments, digits in bases higher than 10, for which you use capital letters A-Z, would not have worked.
First, you need to create these methods (I KNOW, THEY'RE SUPER-LONG. DEAL WITH IT. Oh yeah, copy+paste is strongly advised. And this may just set the Scratch record for longest post. Definitely the Block Library record. ) :
Int: t1 toBase: t2 | digit t1s t1so a | t1 isInf ifTrue: [^ 0]. t1 isNaN ifTrue: [^ 0]. t2 isInf ifTrue: [^ 0]. t2 isNaN ifTrue: [^ 0]. t2 = 0 ifTrue: [^ 0]. t2 = -1 ifTrue: [^ 0]. t2 > 36 ifTrue: [^ 0]. t2 < -36 ifTrue: [^ 0]. t2 = 1 ifTrue: [a _ '1' asString. t1 - 1 timesRepeat: [a _ a asString , '1' asString]. ^ a]. t1 = t1 rounded ifFalse: [^ 0]. t1s _ t1. t2 < 0 ifTrue: [t1s _ t1s * -1]. t1so _ t1s. digit _ (t1s \\ t2) abs. t1so / t2 < (t1so / t2) rounded ifTrue: [t1s _ (t1s / t2) rounded. t1s _ t1s - 1]. t1so / t2 < (t1so / t2) rounded ifFalse: [t1s _ (t1s / t2) rounded]. digit = 10 ifTrue: [digit _ 'A' asString]. digit = 11 ifTrue: [digit _ 'B' asString]. digit = 12 ifTrue: [digit _ 'C' asString]. digit = 13 ifTrue: [digit _ 'D' asString]. digit = 14 ifTrue: [digit _ 'E' asString]. digit = 15 ifTrue: [digit _ 'F' asString]. digit = 16 ifTrue: [digit _ 'G' asString]. digit = 17 ifTrue: [digit _ 'H' asString]. digit = 18 ifTrue: [digit _ 'I' asString]. digit = 19 ifTrue: [digit _ 'J' asString]. digit = 20 ifTrue: [digit _ 'K' asString]. digit = 21 ifTrue: [digit _ 'L' asString]. digit = 22 ifTrue: [digit _ 'M' asString]. digit = 23 ifTrue: [digit _ 'N' asString]. digit = 24 ifTrue: [digit _ 'O' asString]. digit = 25 ifTrue: [digit _ 'P' asString]. digit = 26 ifTrue: [digit _ 'Q' asString]. digit = 27 ifTrue: [digit _ 'R' asString]. digit = 28 ifTrue: [digit _ 'S' asString]. digit = 29 ifTrue: [digit _ 'T' asString]. digit = 30 ifTrue: [digit _ 'U' asString]. digit = 31 ifTrue: [digit _ 'V' asString]. digit = 32 ifTrue: [digit _ 'W' asString]. digit = 33 ifTrue: [digit _ 'X' asString]. digit = 34 ifTrue: [digit _ 'Y' asString]. digit = 35 ifTrue: [digit _ 'Z' asString]. a _ digit asString. [t1s abs > 0] whileTrue: [t1so _ t1s. digit _ (t1s \\ t2) abs. t1so / t2 < (t1so / t2) rounded ifTrue: [t1s _ (t1s / t2) rounded. t1s _ t1s - 1]. t1so / t2 < (t1so / t2) rounded ifFalse: [t1s _ (t1s / t2) rounded]. digit = 10 ifTrue: [digit _ 'A' asString]. digit = 11 ifTrue: [digit _ 'B' asString]. digit = 12 ifTrue: [digit _ 'C' asString]. digit = 13 ifTrue: [digit _ 'D' asString]. digit = 14 ifTrue: [digit _ 'E' asString]. digit = 15 ifTrue: [digit _ 'F' asString]. digit = 16 ifTrue: [digit _ 'G' asString]. digit = 17 ifTrue: [digit _ 'H' asString]. digit = 18 ifTrue: [digit _ 'I' asString]. digit = 19 ifTrue: [digit _ 'J' asString]. digit = 20 ifTrue: [digit _ 'K' asString]. digit = 21 ifTrue: [digit _ 'L' asString]. digit = 22 ifTrue: [digit _ 'M' asString]. digit = 23 ifTrue: [digit _ 'N' asString]. digit = 24 ifTrue: [digit _ 'O' asString]. digit = 25 ifTrue: [digit _ 'P' asString]. digit = 26 ifTrue: [digit _ 'Q' asString]. digit = 27 ifTrue: [digit _ 'R' asString]. digit = 28 ifTrue: [digit _ 'S' asString]. digit = 29 ifTrue: [digit _ 'T' asString]. digit = 30 ifTrue: [digit _ 'U' asString]. digit = 31 ifTrue: [digit _ 'V' asString]. digit = 32 ifTrue: [digit _ 'W' asString]. digit = 33 ifTrue: [digit _ 'X' asString]. digit = 34 ifTrue: [digit _ 'Y' asString]. digit = 35 ifTrue: [digit _ 'Z' asString]. a _ digit asString , a asString]. t1 < 0 ifTrue: [t2 > 0 ifTrue: [a _ '-' asString , a asString]]. ^ a
InBase: t2 Int: t1 | valid letter value total place | t2 isNil ifTrue: [^ 0]. t1 isNil ifTrue: [^ 0]. t2 isInf ifTrue: [^ 0]. t2 isNaN ifTrue: [^ 0]. t2 = 0 ifTrue: [^ 0]. t2 = -1 ifTrue: [^ 0]. t2 > 36 ifTrue: [^ 0]. t2 < -36 ifTrue: [^ 0]. t2 = t2 rounded ifFalse: [^ 0]. letter _ self stringLength: t1. place _ 1. total _ 0. (self stringLength: t1) timesRepeat: [valid _ false. (self letter: letter of: t1) asNumberNoError > 0 ifTrue: [(self letter: letter of: t1) asNumber < t2 ifTrue: [valid _ true. value _ (self letter: letter of: t1) asNumber]]. (self letter: letter of: t1) = '0' ifTrue: [valid _ true. value _ 0]. (self letter: letter of: t1) = 'A' ifTrue: [valid _ true. value _ 10]. (self letter: letter of: t1) = 'B' ifTrue: [valid _ true. value _ 11]. (self letter: letter of: t1) = 'C' ifTrue: [valid _ true. value _ 12]. (self letter: letter of: t1) = 'D' ifTrue: [valid _ true. value _ 13]. (self letter: letter of: t1) = 'E' ifTrue: [valid _ true. value _ 14]. (self letter: letter of: t1) = 'F' ifTrue: [valid _ true. value _ 15]. (self letter: letter of: t1) = 'G' ifTrue: [valid _ true. value _ 16]. (self letter: letter of: t1) = 'H' ifTrue: [valid _ true. value _ 17]. (self letter: letter of: t1) = 'I' ifTrue: [valid _ true. value _ 18]. (self letter: letter of: t1) = 'J' ifTrue: [valid _ true. value _ 19]. (self letter: letter of: t1) = 'K' ifTrue: [valid _ true. value _ 20]. (self letter: letter of: t1) = 'L' ifTrue: [valid _ true. value _ 21]. (self letter: letter of: t1) = 'M' ifTrue: [valid _ true. value _ 22]. (self letter: letter of: t1) = 'N' ifTrue: [valid _ true. value _ 23]. (self letter: letter of: t1) = 'O' ifTrue: [valid _ true. value _ 24]. (self letter: letter of: t1) = 'P' ifTrue: [valid _ true. value _ 25]. (self letter: letter of: t1) = 'Q' ifTrue: [valid _ true. value _ 26]. (self letter: letter of: t1) = 'R' ifTrue: [valid _ true. value _ 27]. (self letter: letter of: t1) = 'S' ifTrue: [valid _ true. value _ 28]. (self letter: letter of: t1) = 'T' ifTrue: [valid _ true. value _ 29]. (self letter: letter of: t1) = 'U' ifTrue: [valid _ true. value _ 30]. (self letter: letter of: t1) = 'V' ifTrue: [valid _ true. value _ 31]. (self letter: letter of: t1) = 'W' ifTrue: [valid _ true. value _ 32]. (self letter: letter of: t1) = 'X' ifTrue: [valid _ true. value _ 33]. (self letter: letter of: t1) = 'Y' ifTrue: [valid _ true. value _ 34]. (self letter: letter of: t1) = 'Z' ifTrue: [valid _ true. value _ 35]. valid = false ifTrue: [^ 0]. total _ total + (value * (t2 raisedTo: place - 1)). letter _ letter - 1. place _ place + 1]. (self letter: 1 of: t1) = '-' ifTrue: [total _ total * -1]. ^ total
Those methods were important because every other block references them. Otherwise, we would have had to copy+paste that into all these methods, sometimes more than once!
If you want, you can create these blockspecs:
('base10 integer %n to base %n' #r #Int:toBase:) ('base%n integer %s to base10' #r #InBase:Int:)
to create these blocks:
but I don't really recommend those, since the next block is much more versatile and can be used to easily do the same thing.
Now, this block is really useful:
('base%n integer %s to base%n' #r #InBase:Int:toBase:)
InBase: t1 Int: t2 toBase: t3 ^ self Int: (self InBase: t1 Int: t2) toBase: t3
See, all the other methods are much shorter, since we made the first two.
To help with numerical operations in other bases:
('(base%n integers) %s + %s' #r #InBase:add:to:) ('(base%n integers) %s - %s' #r #InBase:sub:to:) ('(base%n integers) %s * %s' #r #InBase:mult:to:) ('(base%n integers) %s / %s' #r #InBase:div:to:) ('(base%n integers) %s mod %s' #r #InBase:mod:to:)
InBase: t1 add: t2 to: t3 ^ self Int: (self InBase: t1 Int: t2) + (self InBase: t1 Int: t3) toBase: t1
InBase: t1 sub: t2 to: t3 ^ self Int: (self InBase: t1 Int: t2) - (self InBase: t1 Int: t3) toBase: t1
InBase: t1 mult: t2 to: t3 ^ self Int: (self InBase: t1 Int: t2) * (self InBase: t1 Int: t3) toBase: t1
InBase: t1 div: t2 to: t3 | t4 | (self InBase: t1 Int: t3) = 0 ifTrue: [^ 0]. t4 _ (self InBase: t1 Int: t2) / (self InBase: t1 Int: t3). t4 = t4 rounded ifTrue: [^ self Int: t4 toBase: t1]. ^ 0
InBase: t1 mod: t2 to: t3 ^ self Int: (self InBase: t1 Int: t2) \\ (self InBase: t1 Int: t3) toBase: t1
And when you need more control over the bases:
('base%n int %s + base%n int %s, return base%n' #r #InBase:Int:addBase:Int:return:) ('base%n int %s - base%n int %s, return base%n' #r #InBase:Int:subBase:Int:return:) ('base%n int %s * base%n int %s, return base%n' #r #InBase:Int:multBase:Int:return:) ('base%n int %s / base%n int %s, return base%n' #r #InBase:Int:divBase:Int:return:) ('base%n int %s mod base%n int %s, return base%n' #r #InBase:Int:modBase:Int:return:)
InBase: t1 Int: t2 addBase: t3 Int: t4 return: t5 ^ self Int: (self InBase: t1 Int: t2) + (self InBase: t3 Int: t4) toBase: t5
InBase: t1 Int: t2 subBase: t3 Int: t4 return: t5 ^ self Int: (self InBase: t1 Int: t2) - (self InBase: t3 Int: t4) toBase: t5
InBase: t1 Int: t2 multBase: t3 Int: t4 return: t5 ^ self Int: (self InBase: t1 Int: t2) * (self InBase: t3 Int: t4) toBase: t5
InBase: t1 Int: t2 divBase: t3 Int: t4 return: t5 | t6 | (self InBase: t3 Int: t4) = 0 ifTrue: [^ 0]. t6 _ (self InBase: t1 Int: t2) / (self InBase: t3 Int: t4). t6 = t6 rounded ifTrue: [^ self Int: t6 toBase: t5]. ^ 0
InBase: t1 Int: t2 modBase: t3 Int: t4 return: t5 ^ self Int: (self InBase: t1 Int: t2) \\ (self InBase: t3 Int: t4) toBase: t5
Wow, you actually read all of that?
...............
Ha! I have uncovered your identity as an alien spy threatening to take over the world!!! How do I know that?
Because it's not human to be able to read all that. Reading this post puts those "do this as long as you can before you get bored" projects to shame.
But I can use an ability like that. Go check my spelling.
Last edited by Greenatic (2011-07-28 18:03:12)
Offline
SSBBM wrote:
Shouldn't we get rid of the 1st anniversary logos?
I think until August 1st.
Greenatic, it looks like the next one will be a mega-update!
And I did read all that, except for the code.
You missed some capitals, but your spelling is all good. ;P
Offline
SSBBM wrote:
Sidharth wrote:
I have a nice BYOB block that I think you do not already have:
http://i.imgur.com/FpG60.gif
.ysp file is here. (mediafire download link page)I don't see your block in the download...
LOL oops
Here is the real one: http://www.mediafire.com/?ngj092ui6d2nk15
EDIT: I was sleepy
Last edited by Sidharth (2011-07-29 00:48:28)
Offline
Ok, more blocks from me:
Download .ysp file
EDIT: Tell me if they do not work, and I will fix them. There might be mistakes; I'm sleepy now too
Last edited by Sidharth (2011-07-29 02:15:11)
Offline
Just to let people know, I'm off to Switzerland for a week (leaving tomorrrow early morning), I'm not going to be around until Monday the 8th of August as a result. I may be able to pop in occasionally but nothing much! I'm sure the other librarians can continue doing an excellent job while I'm gone!
Tschüss, bis später.
Offline
sparks wrote:
This block does not support .jpg format, is there a way to make it so?
Code:
| img newC | t1_t1 asString. (t1 asLowercase endsWith: '.gif') ifTrue: [ img _ (GIFReadWriter new setStream: (HTTPSocket httpGet: t1)) nextImage.] ifFalse: [ (t1 asLowercase endsWith: '.png') ifTrue: [ img _ (PNGReadWriter createAFormFrom: (HTTPSocket httpGet: t1) contents) first] ifFalse: [ img _ HTTPSocket httpJpeg: t1]]. newC _ ImageMedia new form: img; mediaName: (self unusedMediaNameFromBaseName: (self defaultImageMedia mediaName)). self addMediaItem: newC.
I just realized something. You didn't declare t1 as a temporary variable, so I'm assuming it's an argument. In which case, isn't
t1 _ t1 asString.
invalid? You can't change an argument...of course, that's assuming t1 is an argument.
BTW, is anyone queueing Scratch blocks?
Last edited by Greenatic (2011-07-29 11:08:42)
Offline
No.
Next week I'll try to run another massive update; I'm in the middle of a move.
Offline