Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1] 2
Author Topic: Norwegian Pixels Sketch
krummrey
Advanced
Posts: 66
Permalink
Post Norwegian Pixels Sketch
on: January 4, 2016, 19:46
Quote

Since I don't have the Polargraph shield but wanted to have a spiral like the Norwegian Pixels I wrote a sketch that will produce one that I can send from the Polargraph controller. Not as elegant, but it works:

Anyone interested in refining it?
It dumps a PDF, Is there an easy way to export a SVG from Processing?
https://github.com/krummrey/SpiralFromImage

Image

krummrey
Advanced
Posts: 66
Permalink
Post Re: Norwegian Pixels Sketch
on: January 4, 2016, 19:48
Quote

Forgot the closeup
Image

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Norwegian Pixels Sketch
on: January 4, 2016, 20:31
Quote

Looks beautiful Krummrey, very nice work! Inkscape can read PDFs and export SVGs, but I suppose you know that.

There might be more elegant ways of doing it now, but Geomerative is able to export SVGs, it's quite easy to integrate.

sn

krummrey
Advanced
Posts: 66
Permalink
Post Re: Norwegian Pixels Sketch
on: January 5, 2016, 00:50
Quote

The Geomerative Documentation is little over my head. Having trouble understanding it.
I just wrote the SVG export into the sketch. They are just straight lines....

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Norwegian Pixels Sketch
on: January 5, 2016, 21:40
Quote

Ha ha! When I thought about how I'd done the SVG export in the Polarweb software, I remember that that was all I'd done too 🙂

max_bol
Newbie
Posts: 2
Permalink
Post Re: Norwegian Pixels Sketch
on: January 11, 2016, 16:46
Quote

Hey krummery,

Thanks for the code, I've had great fun playing around with the results!

I hope you don't mind but I took the time to add a basic UI and controls to your original sketch, please forgive the sloppy coding, its my first real foray into Processing so I'm sure there is a neater manner of doing some things.

The code can be found here: https://github.com/bol-max/SpiralFromImageGUI
I haven't really updated the documentation provided, but the only real change is that generated SVG's are placed into an Output/ folder in the base runtime folder.

It's worth noting that the Processing sketch will need ControlP5 libraries to compile, but I've thrown up .exe's for Win 32 and 64.

krummrey
Advanced
Posts: 66
Permalink
Post Re: Norwegian Pixels Sketch
on: January 11, 2016, 18:08
Quote

WOW, that's awesome. I love it.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Norwegian Pixels Sketch
on: January 11, 2016, 21:47
Quote

max bol it'd be polite to create this as a fork from krummrey's original repo, which allows him to pull your changes into his easily. Also if you're going to change the name of the project, you should make the name of the sketch match it so Processing can load the sketch.

Neat additions though - and Krummrey, I hadn't noticed that you'd released the code for this until now - great work! Except the Polargraph controller can't load the SVGs it outputs for me? Does it work ok for you guys?

sn

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Norwegian Pixels Sketch
on: January 11, 2016, 23:28
Quote

Sandy, I've got my polargraph drawing an SVG generated from krummrey's original pde. Most likely I did the usual SVG hygiene in Inkscape, though (I made the file last week, so I'm not sure what I did).

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Norwegian Pixels Sketch
on: January 12, 2016, 23:05
Quote

Hmph! Just me then!

max_bol
Newbie
Posts: 2
Permalink
Post Re: Norwegian Pixels Sketch
on: January 13, 2016, 00:13
Quote

Hi Sandy,

My apologies for the late reply, to be honest I have no idea how github functions and I am still rather confused as to how it functions after having had a read and a play around with it. I'm unfamiliar with their etiquette so forgive me if I'm stepping on anyone's toes, I'll do that as soon as I can. I think I've managed to sort it out, sorry about that earlier and thanks for the tip.

I think you might be having trouble reading the files produced by the original because of some mismatched SVG definitions in the header:

Line 167:

output.println("<svg width=\"px\" height=\"px\" viewBox=\"0 0 1200 400\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");

The undeclared width and height tags seemed to give the processing svg reader some issues, setting these to the width and height of the loaded PImage seemed to fix the problem for me. Hope this helps.

Max

p01c
Newbie
Posts: 5
Permalink
Post Re: Norwegian Pixels Sketch
on: January 13, 2016, 10:49
Quote

Love your script, had some fantastic results:

Image
Image

Thanks!

dickholmer
Beginner
Posts: 39
Permalink
Post Re: Norwegian Pixels Sketch
on: January 13, 2016, 16:54
Quote

hi, i had the same idea to combine a spiral and norwegian pixel during the christmas holidays. and i also really really love the result. my code and my convertion to an SVG file is really very very quick and dirty. the only thing which causes some trouble is the size of the SVG file. the polargraph controller does need some time to open the approx. 1.5MB file. this is why i tried to minimize the size by having longer lines in bright areas and shorter lines in dark areas. which also gives a better contrast. the printing on the polargraph was unexpected fast. why not add this style direct to the controller? 🙂
cheers
thomas

Image

krummrey
Advanced
Posts: 66
Permalink
Post Re: Norwegian Pixels Sketch
on: March 13, 2016, 18:23
Quote

I reworked the sketch a little:

  • removed PDF export
  • added and reworked CP5 gui (taken from max_bol's fork)
  • fixed wrong SVG header

https://github.com/krummrey/SpiralFromImage

stereoeric
Newbie
Posts: 22
Permalink
stereoeric
Post Re: Norwegian Pixels Sketch
on: March 13, 2016, 21:42
Quote

As I am essentially computer illiterate, and know nothing about Processing, can someone lead me by the hand and tell me how to load a photo into the "SpiralfromImage" Processing program, and what format it has to be in?

Thank you

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Norwegian Pixels Sketch
on: March 13, 2016, 21:53
Quote

krummrey, I'm getting this:

Image

krummrey
Advanced
Posts: 66
Permalink
Post Re: Norwegian Pixels Sketch
on: March 14, 2016, 12:31
Quote

@kongorilla Looks like you're missing the SVG.pde that goes along with it. Moved it out so that I can use it in other projects also. Just drop the file into the same folder as the sketch is.

@stereoeric It is a sketch that runs under the Processing environment. It should take JPEG, PNG, GIF - probably more - as inputs. It resizes everything internally, so it doesn't matter what size your provided image is.

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: Norwegian Pixels Sketch
on: March 14, 2016, 14:45
Quote

Thanks, krummrey! Working great now. The feature mentioned in your 'todo' section would be fantastic (being able to manually choose the center point).

krummrey
Advanced
Posts: 66
Permalink
Post Re: Norwegian Pixels Sketch
on: March 14, 2016, 16:35
Quote

@kongorilla Yes, would love to see that happen in the next version.

@sandy Is there an easy way to generate the gcode within this sketch? Saw the polargraphlib that probably can do this. I have cartesian coordinates. Is there a function/class that I can pass these to and recieve the polar coordinates?
Or what does it take to calculate them on the fly? Machine width and height, steps per rev and mm per rev?
polarx = magic formular (cartesianx)
polary = magic formular (cartesiany)

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Norwegian Pixels Sketch
on: March 15, 2016, 21:28
Quote

Hi yes the calculation itself is quite straightforward, all you need to know is the width of the machine:

  public PVector asNativeCoords(float cartX, float cartY)
  {
    float distA = dist(0,0,cartX, cartY);
    float distB = dist(getWidth(),0,cartX, cartY);
    PVector pgCoords = new PVector(distA, distB);
    return pgCoords;
  }
  
  
  public PVector asCartesianCoords(PVector pgCoords)
  {
    float calcX = int((pow(getWidth(), 2) - pow(pgCoords.y, 2) + pow(pgCoords.x, 2)) / (getWidth()*2));
    float calcY = int(sqrt(pow(pgCoords.x,2)-pow(calcX,2)));
    PVector vect = new PVector(calcX, calcY);
    return vect;
  }

https://github.com/euphy/polargraphcontroller/blob/master/Machine.pde#L314-L329

It's made a bit complicated by having to convert units around (steps to mm to pixels etc) which gets a bit messy.

Polargraphlib was intended to do exactly that, be a general-purpose library that could be plugged into a processing sketch and would automatically "draw" lines as the app drew them. Never really got moving. Rolling back into java after being a free man (using Python) made me too sad.

Pages: [1] 2
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.049 seconds.