Le 20/07/2015 11:03, Mianlai Zhou a écrit :
Hi,
Thanks for your answer. I meant the former, i.e., a 2D pict of a ball
with some shading to make it look 3D.
Is there any quick way to do it or I have to implement the algorithm
by myself?
The answer is more general than just in the context of Racket...
Do you want something of this kind (sorry for the quality, it was just a
30 second test, it could be better).
The "algorithm" is just a radial gradient, and a clipping circle. Its
'softness' translates visually into the amount of "specularity", or the
roughness, if you prefer. Some exquisite parametrization may be found
anywhere, e. g. here (a page on SVG):
http://doc.qt.io/qt-5/qtsvg-svgviewer-files-spheres-svg.html
which gives:
See also the book
"Flash 3D Cheats Most Wanted" by Yard, Balkan, et al.
Now, the Racket solution ...
You will find the information about radial gradients (with examples)
here, in your local doc:
... /doc/draw/radial-gradient_.html?q=gradient#%28tech._radial._gradient%29
On line:
http://docs.racket-lang.org/draw/radial-gradient_.html#%28tech._radial._gradient%29
To have something more realistic, you should combine (at least) the
diffuse and specular lighting, which is non-linear. Quite easy, and
implemented in the 3D simulation in SVG, and several drawing packages,
but all depends on your ambitions. For simple drawings, a quite trivial
CSS suffices, there is a radial gradient in the standard, and multiple
colour stops are possible.
http://www.w3schools.com/css/css3_gradients.asp
Best regards
Jerzy Karczmarczuk
/Caen, France/
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.