How do i set the pixel size of patches? [duplicate] - netlogo

This question already has answers here:
Is the placement of set patch-size within my code correct and is set the right command to use?
(2 answers)
Closed 8 years ago.
I need to be able to draw out roads in the u.i. It is therefore important that I am able to adjust the size of the patches that I use to do this. Please could somebody give an example of source code that I may use to achieve this? cheers

No source code as such but you can make the roads more than one patch wide or give the patches a width variable maybe using pcolor for
visualization.
Ask patches with[road?][set pcolor brown + width]

Related

Is it possible to tell the human readable color (ex. pink, white) from RGB/Hex code in Swift? [duplicate]

This question already has answers here:
Check if color is blue(ish), red(ish), green(ish),
(3 answers)
Closed 1 year ago.
I'm trying to build an app for a class project that finds the most dominant color of an image. While it's not hard to extract the most dominant colors RBG code, I was wondering if there is a way to use this code to get us the name of the color like red color or blue color.
I understand this would be technically complex since there are so many different RGB values but I was wondering if that had been done before. I'm using Swift to develop this app.
This question is not swift related but more a general programming problem. There are multiple ways to solve this.
The first approach would be to create a list of colors you want to separate, or get it from somewhere. Then create a function that maps a random RGB value onto the nearest values from the list (you can do least squares or any kind of definition of 'nearest values').
Another solution would be to again use a mapping but based on the angle of the rgb values when mapped into an rgb color wheel (https://www.pikpng.com/pngl/b/113-1130205_alt-text-rgb-led-color-mixing-chart-clipart.png, http://www.procato.com/rgb+index/).
Anyway, there are multiple solutions online and also on stack overflow (RGB color space to raw color name mapping, https://github.com/ayushoriginal/Optimized-RGB-To-ColorName)

Mapbox cluster colors according a custom property value

I'm working now with mapbox, I'm new in this, what I want to do is set the color of points and clusters according to a custom property 'rains'. For example if the 'rains' property is below 5 the color should be white, if is betweet 5 and 10 should be light blue and so on.I dont have a problem with the invidual points but with the clusters what I want to do is an average of the 'rains' values and then use the same logic.
I'm realy stuck with this, hope someone can help me!

Dynamic turtle creation in netlogo

I am new to netlogo and was hoping if someone can help me with how to create turtles based on the user input.
In the interface tab i have a slider whose value ranges between 2 & 10. Depending on the value defined by the user using this slider, that many number of turtles should be created.
I tried using multiple if statements but there is a problem in the succeeding steps.
if (slider-value = 2) [create2]
if (slider-value = 3) [create3]
if (slider-value = 4) [create4]
if (slider-value = 5) [create5]
After creating the turtles using the above if conditions, i have to assign some rules to each individual turtle, and i tried again using multiple if statements. But it doesn't seem to work.
Can someone suggest a way, would really appreciate the help.
Thanks in advance!
Regards
You could more simply use the slider thus
create-turtles slider-value [
;things you want the turtles to do for example
set heading 4 * random 90
set shape "turtle"
set color green + random-normal 0 4
]
is this what you are looking for?
I recommend a switch statement.
A switch statement cycles through all your possible commands ,typically with an int. And then selects the match command.
So for example I could make a switch statement that when user inputs the up arrow. the int 1 is the input. this is matched to a command that tells the turtle to move up so many pixels/units/cubes.
I hope that helps.

Percentage whiteness of UIImage [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Good way to calculate ‘brightness’ of UIImage?
For a UIImage how can you determine the percentage whiteness of the whole image?
cheers
Depending on your definition of 'whiteness', you may be able to simply draw the image to a 1x1 CGBitmapContextRef, then check the whiteness of that single pixel.

How can I identify unfilled ovals in a PDF document using CAM::PDF? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to identify unfilled ovals in a PDF file. After that, I should fill them with color and I need coordinates of ovals with page numbers. Can anybody help me how to solve this using CAM::PDF?
The $doc->traverse($dereference, $node, $callbackfunc, $callbackdata) seems pretty promising. Check and see what's the oval's type.
Looking at the PDF Specs, I would say you have quite challenge in front of you:
PDF provides five types of graphics objects:
A path object is an arbitrary shape made up of straight lines, rectangles, and cubic Bézier curves. A path may intersect itself and may have disconnected sections and holes. A path object ends with one or more painting operators that specify whether the path shall be stroked, filled, used as a clipping boundary, or some combination of these operations.
A text object ...
An external object (XObject) is an object defined outside the content stream and referenced as a named resource (see 7.8.3, "Resource Dictionaries"). The interpretation of an XObject depends on its type. ...
An inline image object uses a special syntax to express the data for a small image directly within the content stream.
A shading object describes a geometric shape whose colour is an arbitrary function of position within the shape.
Therefore, at a minimum, one would need to know whether the ovals you are interested in are paths or external objects or inline image objects or shading objects.
Then, you need an appropriate algorithm which can decide whether an object of that type is an oval. Then, you need to figure out what unfilled means. Then, you need to figure out how to fill them.
It seems unlikely to me that anyone would put in that much effort to give you a ready-made solution.
It may actually be simpler to render the PDF to a grayscale bitmap and use simple shape recognition to determine filled from unfilled ovals. If you can reliably determine where the ovals are going to be (I'm assuming this is coming from a form, so the position of the ovals would be standard), you can make a simple heuristic (e.g. if 70% of pixels are 50% gray or higher) to determine what kind of oval it is.
For example in this situation:
[ ] [ ] [ ] [X]
[ ] [X] [ ] [ ]
[ ] [ ] [X] [ ]
You can split the ovals using a grid:
[ ] | [ ] | [ ] | [X]
------+-----------+----------+------
[ ] | [X] | [ ] | [ ]
------+-----------+----------+------
[ ] | [ ] | [X] | [ ]
Then from there you just loop over the grid, applying that simple heuristic to each cell.