Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Pic v1 is uploaded - draw into images

BortelsBortels Mod
edited December 2011 in Code Sharing Posts: 1,557
So - I have this fault where nothing ever is "done" - I will tweak things forever if I'm allowed to.

In the spirit of trying to break that habit, I present Pic version 1.

http://bortels.posterous.com/pic-v1

Pic is a wrapper library for Codea's image() call that adds line drawing, regular n-gons, irregular polygons, and filled irregular polygons. Missing but planned to be added are filled regular polygons, flood fill, pseudo-3D Sphere drawing, and whatever else my fevered mind comes up with. I am open to suggestions, constructive criticism, and patches.

See the Main tab for examples of use, and the ugliest moose evar. Yes, it's a moose. Or it's supposed to be. I've been sick, let's see you do better doped up on painkillers from a root canal. It used to be an upside-down moose, but Simeon fixed that accidentally :-)

I chose Pic because image was already in use. and because it's short. I'm not 100% happy with the name, open to better suggestions.

Note the calling convention is generally to pass a table with named parameters, *or* a bunch of arguments - both should work, and missing arguments will be filled with reasonable defaults when possible.

Note also that when fill() starts returning current fill colors, I'll be defaulting to those when you make a Pic object rather than boring old white.

Comments

  • beebee
    Posts: 381
    No screenshot? I think screenshot is important so other people may look what it is all about before download the code. It will also help others to decide whether they need/interested to download the code or not. :)
  • BortelsBortels Mod
    Posts: 1,557
    The moose is just too ugly. If someone provides me with better coordinate pairs for a better moose, I'll post a screenshot.
  • edited December 2011 Posts: 273
    @Bortels you call that a moose? Looks to me rather suspiciously like a pink puppy with a slightly distorted box stuck on his head... :) but regardless of what we would call it... boy oh boy am I grateful for your work here Mr. Bortels! Thank you sir.

    Edit: I've been making a small app to experiment with Truchet tilings (http://en.wikipedia.org/wiki/Sebastien_Truchet) and your filledpoly function and triangle example have appeared at the perfect moment.
  • Posts: 1,223
    Very nice, @Bortels. One of the great things about the community developing here is that you can get good feedback on a project in progress, and there are folks ready to look at things still in need of a good polish--not that this project needs it. Good work.
  • Posts: 35

    Question, @Bortels--how would I get this pic1.codea file into a form I can copy/paste? I followed the link, neither IE nor Chrome will open the file (complains of an invalid character), but I can kind of see it saving and opening as .txt

    I've been working on similar experiments for my own edification (from my graphics textbook of 20 years ago!), so I'm gradually getting a basic understanding of principles again. Up to polygons, regular Ngons, prime rosettes now--still working on understanding more than the most basic features/properties of vectors.

    But I would still like to refine it or distribute over some classes to make it more manageable, as I add more to it and 'Main' gets longer and longer. Sometimes I calc/draw as I go, sometimes storing as points -- would like to make that more consistent as well. Sounds like we're similar in that way, wanting to constantly rewrite and refine!

    I was overly pleased myself with the result of a 'polyspirals' experiment (code posted in a Trig thread, but without a screen shot or video to make it enticing.) That version's not horribly clean; also, I found increasing the range of the Distance parameter makes it even more fun, as well as adding (random) colour before each spiral is drawn. Then it seems some of what I did could be replaced by better/standard functions or more efficient code...and on it goes. I might post a version of it again, if I'm ever reasonably satisfied with it!

  • Posts: 154

    I will :X it if you can make it so you can copy and paste [-O<

  • Posts: 35

    I gather it was posted back when Codea could share projects directly.

  • Posts: 35

    Ah, I see in the FAQ(!) that something like iExplorer can still upload the .codea project files directly. (Have tried iExplorer, but haven't figured it out yet. Next coffee break...but @Connorbot999, I thought you'd like the hint in the meantime.)

  • Posts: 35

    Well, that way (iExplorer), madness lies--on my desktop, it got saved as an .xml file (that no browser will open), renaming it to .codea and getting into the proper directory in Codea (com.twolivesleft.Codify) Documents via iExplorer (after the 10th restart because opening 'too many directories') -- it crashes Codea, because it's not really a 'codea' file, but some corrupted xml?

    I would not suggest it, @Connorbot999! I'm not sure how to extract this otherwise. (and iExplorer might be great, but I'm on neither Facebook, Twitter, nor Google+ -- so I will be blessed forevermore with its splash screen to Help spread the word of its name change...)

  • Posts: 35

    From the looks of things, a .codea file is really a directory, consisting of the other component files: Data.plist, Info.plist, Main.lua and others from the looks of some of my projects. (Who knew?) I just don't see how to get those extracted from this link.

  • BortelsBortels Mod
    Posts: 1,557

    The Pic library is very obsolete (much of what it does would be much faster with meshes), but there might be some juicy chunks left to pick thru. Yes, the .codea format is unfortunately obsolete; but there is hope:

    http://home.bortels.us/decodea/

    That page will let you decode a .codea file into easily cut-and-pastable chunks.

    The results, for the Pic-v1 library I linked above, are here:

    http://home.bortels.us/decodea/results/Pic-v1.html

  • Posts: 115

    You can open the .codea files in the free Notepad++ for your PC (perhaps available for other OS) and then cut and paste into Codea. Just avoid pasting lines that Codea will not recognize.

  • Posts: 35

    :"> Much appreciated, thanks both for the tips! (I see newer versions of the Pic library too.)

    I'm sure much is available standardly I don't yet understand, and that's why it's back to a computer graphics textbook for me for now. Starting from 'line', to eventually build up/refresh concepts of geometry -- and linear algebra -- so that when I eventually use a mesh, or want the dot product or length or normalized vector or angle between two vectors -- I know why! What transformations are and what accomplishes them, etc.

    But knowing what to do with the .codea files now, I'm sure much more will be revealed to me presently!

Sign In or Register to comment.