Skip to content

Instantly share code, notes, and snippets.

@greyblue9
Created April 13, 2022 04:08
Show Gist options
  • Save greyblue9/7cd408c0a18e44d82326e4dd1081a0c6 to your computer and use it in GitHub Desktop.
Save greyblue9/7cd408c0a18e44d82326e4dd1081a0c6 to your computer and use it in GitHub Desktop.
HTML created by `markdown_py`
<h1>Thank you for using this library! Here are the basic ways to use it:</h1>
<h2>To import, do:</h2>
<blockquote>
<p>from G_Sketch import *</p>
</blockquote>
<h2>To create an object do:</h2>
<blockquote>
<p>my_sketch = Sketch("path/to/file.png")</p>
</blockquote>
<p>There are 3 functions for a sketch:</p>
<blockquote>
<ul>
<li>get_coords()</li>
<li>get_raw_coords()</li>
<li>set_min_distance()</li>
</ul>
</blockquote>
<h2>get_coords()</h2>
<p>This function returns a list of coordinates (stored as tuples). This version is formatted, meaning between separate bodies, there appears the keyword "BREAK", which can help prevent crossing over.</p>
<h2>get_raw_coords()</h2>
<p>This function is exactly the same, except it does not include the keyword "BREAK".</p>
<h2>set_min_distance()</h2>
<p>get_coords() and get_min_coords() return every single pixel found on the outline of an image. If you want to limit these, use this function. It takes in an int as a parameter which sets the minimum distance 2 pixels must be from each other. Note: this changes the pixels value stored in it. Calling set_min_distance(1) will change it back to normal.</p>
<h2>Example code:</h2>
<blockquote>
<p>from G_Sketch import *</p>
<p>sketch = Sketch("G_Sketch/flower.png")</p>
<p>print(sketch.get_coords())</p>
<p>print(sketch.get_raw_coords())</p>
<p>print(len(sketch.get_coords()))</p>
<p>sketch.set_min_distance(5)</p>
<p>print(len(sketch.get_coords()))</p>
</blockquote>
<h1>Happy coding!</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment