• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[Rebol School] REBOL School

Kaj
20-Dec-2012
[1593]
The g: draw line segfaults on 2.7.7
Cyphre
20-Dec-2012
[1594]
works fine on 2.7.8 ( IIRC that was fixed)
Kaj
20-Dec-2012
[1595]
Hm, so does John's example
Cyphre
20-Dec-2012
[1596]
Hmm, I tried here on  REBOL/View 2.7.7.3.1 28-Feb-2010 and it works 
without any crash as well.
Kaj
20-Dec-2012
[1597]
I'm using the Linux version, 4.2
Bo
20-Dec-2012
[1598]
Geomol, thanks for the tutorial.  That was great.

Here's a logo I produced entirely using Rebol draw:

http://respectech.com/respectech.jpg
Henrik
20-Dec-2012
[1599]
That's pretty good, Bo.
Bo
20-Dec-2012
[1600x2]
Now that I think of it, I used VID with some parts done in Draw.
But it was all done in a 'layout block. :-)
Geomol
21-Dec-2012
[1602]
Looks good! DRAW is a strong tool.
Gabriele
21-Dec-2012
[1603]
Kaj, I think I remember the draw crash being a linux bug (or at least 
a non-windows one).
MaxV
21-Dec-2012
[1604]
No, it's false. DRAW works well, the only problem are fonts dispalyed 
on Linux, but there aret ricks to skip them.
Geomol
21-Dec-2012
[1605x2]
Another example is the home button on iPhone 5:
sz: 200x400
img: make image! sz
img/alpha: 255

draw img compose [
	pen none
	fill-pen linear (as-pair 0 sz/y / 2) -50.5 70.5 90.0 1.0 1.0
			45.45.47 9.9.11 108.113.117
	circle (as-pair sz/x - 115 sz/y / 2) 70.5
	fill-pen 1.0.5
	circle (as-pair sz/x - 115 sz/y / 2) 68.5

	reset-matrix

 fill-pen linear (as-pair sz/x - 115 sz/y / 2) -60.5 30.5 45.0 1.0 
 1.0
			161.164.169 161.164.169 89.94.100

 box (as-pair sz/x - 115 - 26 sz/y / 2 - 26) (as-pair sz/x - 115 + 
 26 sz/y / 2 + 26) 10.0
	fill-pen 1.0.5

 box (as-pair sz/x - 115 - 22 sz/y / 2 - 22) (as-pair sz/x - 115 + 
 22 sz/y / 2 + 22) 6.0

	reset-matrix

 fill-pen linear (as-pair 0 sz/y / 2 - 26) -50.5 100.5 90.0 1.0 1.0
			1.0.5.255 200.214.226.224 200.214.226.128
	shape [
		move 154x200
		arc 16x200 68.0 68.0
		arc 154x200 -149.0 68.0
	]
]

view layout [
	backdrop 1.0.5
	image img
]
Pekr
21-Dec-2012
[1607x2]
that's cool!
MaxV could post those examples on the blog :-)
Steeve
21-Dec-2012
[1609]
I don't rememeber who did the neon effect, but here it is.

font-C: make face/font [style: [ bold ] size: 64]
neon: "REBOL BAR"
coord: 30x15
inc: 0.25.25
draw-block: compose [
	line-join round font font-c

 pen (inc * 1 + 255.0.0.230) line-width 11 text vectorial coord neon

 pen (inc * 2 + 255.0.0.205) line-width 9 text vectorial coord neon

 pen (inc * 3 + 255.0.0.180) line-width 8 text vectorial coord neon

 pen (inc * 4 + 255.0.0.155) line-width 7 text vectorial coord neon

 pen (inc * 5 + 255.0.0.130) line-width 6 text vectorial coord neon

 pen (inc * 6 + 255.0.0.105) line-width 5 text vectorial coord neon

 pen (inc * 7 + 255.0.0.80) line-width 4 text vectorial coord neon

 pen (inc * 8 + 255.0.0.55) line-width 3 text vectorial coord neon

 pen (inc * 9 + 255.0.0.30) line-width 2 text vectorial coord neon

 pen (inc * 10 + 255.0.0.5) line-width 1 text vectorial coord neon
]

view/title layout [ box black 450x200 effect [ draw draw-block ] 
] "NEON"
Endo
21-Dec-2012
[1610]
Thank's Geomol, Steeve, these are very good examples of DRAW.
Bo
21-Dec-2012
[1611]
Great examples!
Arnold
21-Dec-2012
[1612]
Steeve, I copied and pasted this on the Mac, but I only see a black 
box in a grey window with title "NEON"
Steeve
21-Dec-2012
[1613]
Vectorial texts only works on Windows IIRC
Arnold
21-Dec-2012
[1614]
ok that explains!
Gabriele
22-Dec-2012
[1615]
MaxV, it works well in the current version.
MaxV
24-Dec-2012
[1616x2]
Done with linux, see: http://rebol2.blogspot.it/2012/12/rebol-draw-on-linux.html
both examples!
Kaj
24-Dec-2012
[1618x2]
Which REBOL version?
2.7.8 Works better for me, but Neon gives a black window
MaxV
2-Jan-2013
[1620]
Did you use the code on the blog post? It's different form the one 
here, I added the font support for Linux: you have to ad the path 
where are the font. Read carefull the post.
Kaj
2-Jan-2013
[1621x2]
Cool, that fixes it
By the way, your first example starts with garbled HTML
MaxV
2-Jan-2013
[1623]
Yes, I noticed it. Just corrected.
Kaj
2-Jan-2013
[1624]
Thanks
Endo
3-Jan-2013
[1625]
Isn't that interesting?
>> ? #a
#a is an issue

>> copy/part next #aaaa 2
== #aa ;<-- issue!

>> pick #aaa 2
== #"a"  ;<-- char!

Why the last one is not an issue?
Jerry
3-Jan-2013
[1626x2]
in R2, issue! is string!, So PICK gets char!. COPY retain the datatype, 
which is issue here.
in R3, you cannot COPY and PICK a issue!, because it's not string 
any more.
BrianH
3-Jan-2013
[1628x3]
(Pardon the level-up in the lesson.)

That's not necessarily the case for R3, it's just the case *now*. 
COPY and PICK are just actions, which could easily be defined for 
the issue! type. You could get most of the R2-like behavior for issues 
in R3 by emulating the way tuples pretend to be series when they're 
really not.


The type classes in Rebol aren't like base classes in OOP languages, 
they are more like behavioral conventions, and those conventions 
are more like Go interfaces than anything OOP. Something is series-like 
to the extent that it behaves like a series is supposed to behave. 
But the acrions that are defined for series types are in some cases 
also defined for other types as well, and the corresponding behavior 
for those types can be similar enough to that of series to allow 
both series and, say, tuples, to be operated on by the same code. 
All that matters is how it seems to act from the outside, not what 
it really is.
We've been making this even more the case in R3 and R2 lately, such 
as when we allowed SELECT to be used on objects (and maps in R3), 
since that is a function that is used to make series act like objects. 
Or when we allowed APPEND to work on objects and maps in R3, since 
there was a corresponding behavior that could be defined for those 
types, but didn't do the same for INSERT because its positional return 
value has no corresponding concept for object-like types.
For issues, we could have COPY return another issue of the same spelling, 
COPY/part return another issue spelled like that portion of the original 
(only integer part values, not offset positions because words don't 
have positions), and PICK return a character just as if the issue 
was a character container like strings are. We would have to avoid 
the positional functions, and the modifying functions could retern 
a different version the way that they do for the similarly immutable 
tuples, but the rest could be emulated as-is.
caelum
31-Jan-2013
[1631]
So I have a block
	account: make object! [
	  name: "James"
	  balance: $100
	  ss-number: #1234-XX-4321
	  deposit:  func [amount] [balance: balance + amount]
	  withdraw: func [amount] [balance: balance - amount]
	]

and I save it

	save %account-object account

then I read it back in

	new-account: load %account-object

account is an object, whilst new-account is a block.


My question is, how do I load the object into new-account as an object? 
So I end up with another object, not a block
GrahamC
31-Jan-2013
[1632]
Have you tried

new-account: do load %account-object
caelum
31-Jan-2013
[1633]
Ah, of course, the missing 'do' word to make it evaluate! Thanks 
GrahamC.
Pekr
31-Jan-2013
[1634]
btw - do might be unsecure, e.g. with CGI code. Maybe 'construct 
would do the trick too, without evaluating the stuff?
caelum
31-Jan-2013
[1635]
I see what you mean. I just read the function summary for 'construct'. 
My objects are encrypted before they get saved anywhere. Thanks for 
the tip Pekr.
Endo
1-Feb-2013
[1636]
you can also use SAVE/ALL to save in serialized form:
>> o: context [a: 1] save/all %file.r o p: load %file.r type? p
== object!
caelum
1-Feb-2013
[1637]
Very usefull. Just what I like about Rebol Thanks Endo.
Maxim
1-Feb-2013
[1638]
the most secure method is to SAVE/ALL AND CONSTRUCT.


also, btw, using MOLD/ALL can save a lot of ram because things like 
hash! and objects! do not get double allocated.  on big datasets 
like I'm  using it means saving 100MB RAM on app startup . :-)


just be carefull with save/all & mold/all   they can corrupt some 
data types just like when /ALL  isn't used.  it does allow much more, 
but it still can create some un-reloadable issues... always test 
it with your current data structures before blindly adopting it.
Endo
1-Feb-2013
[1639]
Yes, here is an example:
>> save/all %file.txt o context [a: self]
>> load %file.txt
** Syntax Error: Missing ] at end-of-script

file.txt file is:
#[object! [
    a: #[object! [...]   ;<---
]]
Maxim
1-Feb-2013
[1640x2]
cyclical data cannot be serialized by any of the internal tools.
though one can write his own mold function which handles the above 
(I once did so).   its just tedious to support all types (there are 
so many)
BrianH
1-Feb-2013
[1642]
Caelum, SAVE/all and MOLD/all will have trouble saving your example 
object in a restorable state. The problem is those functions defined 
in the object, and bound to its fields. Those bindings won't be restored. 
For data that has to be saved and restored safely you're better off 
with having functions that operate on objects, rather than objects 
with functions in them. The "safely" part actually refers to not 
executing code, and you have to execute code to create functions. 
It's better to put your code in one file which you can protect, and 
your data in another file which you can be more wary of.