This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-08-18 11:02:16

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Add a new [draw rectangle] block!

I even have the code!
Note that this block would draw the rectangle relative to the sprite.

Code:

drawRectangleFromX:y:toX:y:color:
| stage fillDirection lastPosition |
stage _ self ownerThatIsA: ScratchStageMorph.
lastPosition _ self referencePosition.
self penColor: t5.
self referencePosition: ((self referencePosition x) + t1) @ ((self referencePosition y) + t2).
((t4 - t2) > 0)
ifTrue: [fillDirection _ 1]
ifFalse: [fillDirection _ -1].
((t4 - t2) abs) timesRepeat:
[
self putPenDown.
stage updateTrailsForm.
self changeXposBy: (t3 - t1).
stage updateTrailsForm.
self putPenUp.
self changeXposBy: (t1 - t3).
self changeYposBy: fillDirection.].
self referencePosition: lastPosition.

The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#2 2010-08-18 11:51:49

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Add a new [draw rectangle] block!

Wow! Maybe even better, it could be drawn at a position of your choosing? (I know you could just say (Go to x:_ y:_) before that block, but it would be nice to have it in one block.)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2010-08-19 01:25:50

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Add a new [draw rectangle] block!

You could just use this simple script:

http://img693.imageshack.us/img693/2155/293rectanglescript.png

hmm


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#4 2010-09-21 19:51:18

zorket
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Add a new [draw rectangle] block!

Hey the code won't work
If the code is right, the class is ('draw rectangle from x: %s y: %s to x: %s y: %s use color: %s' #- #drawRectangleFromX:y:toX:y:color:)

Last edited by zorket (2010-09-22 15:43:05)


Marzipan11 must learn to not spoil

Offline

 

Board footer