Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to make a rating form in iPhone. I am using sqlite manager. If a user clicks the rating form(stars) the rating will be stored in a database. I dont have any idea how to store the rating(stars) in the database. Please give me any idea how to store rating(stars) in a database.
I am following this link how to develop stars rating. Thanks in advance.
Store it as a integer value. Eg. If 2 star save 2 in database.
If you .5 rating also then save it as float. Eg. If 2 and half start then save 2.5 in database.
Depending upon the value draw your stars.
Giving ratings is nothing but the magic of images. Here's the logic for this..
Follow the steps explained below:
1. Prepare 3 images for each star
1.1 Unselected star (Gray Star)
1.2 Half Star (Half Gray/Yellow star)
1.3 Full Star (Yellow star)
2. Initially all 5 stars are fully gray & db value for ratings field is 0
3. Now prepare condition,
3.1 if User clicks one time then it receives half star, the image is changed from gray to half gray & the database value will be changed from 0 to 0.5
3.2 if User clicks again then the image will be changed from half gray to fully green & the database value will be changed from 0.5 to 1.0
Now if user clicks the green star
4.1 the image will be changed from 1.0 to 0.5 and, the ratings field in database will be from 1.0 to 0.5
4.2 if user clicks again the half gray star then the value in the db will be changed from 0.5 to 0 & the image will be fully gray star.
Enjoy Programming !
Related
I'm relatively new to Pine and was having trouble with a couple of things.
So I've got a indicator that I want to look back for the last 5 full days of activity, however not each stock trades in the premarket/afterhours so I want to be able to look back say 5 days and then calculate the number of bars on the time frame (i.e. for a 5 min or hourly resolution). That way I can calculate the number of bars present on the current ticker for that time frame and adjust my indicator length (instead of just having a constant figure of 80 bars or whatever).
The second thing I want to do is only have the indicator update on the completion of a full bar (for example the hourly resolution). So I want it to only calculate up to x-1 bars. Right now I'm finding that it's updating on each new tick. ( I was able to figure this one out, just changed it from i= 0 to length -1 to i=1 to length).
Any help is greatly appreciated.
Thanks,
A
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 2 years ago.
Improve this question
Need to draw a custom world map drawing either the complete world map or a certain region. Also highlighting different regions with different colours.
I have tried https://github.com/KiloKilo/WorldMatrix. I am able to colour the regions but unable to draw custom regions and provide custom colour to certain regions. Unable to find any other library.
Using below code, it shows nothing
let generator = WorldMatrixGenerator()
// Set the number of columns per rows (Default: 100)
generator.columns = 20
// Set your desired map cutting (Default: .world)
// use .custom(north, east, south, west) for a custom bounding
generator.mapCutting = .europe
// Set the output type (.enum, .ascii, .emoji) (Default: .enum)
generator.exportType = .enum
// Generates the world array
generator.generate()
Basically want to achieve the one in the image. Can someone let me know how can draw custom regions?
Thanks for the help in advance.
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 5 years ago.
Improve this question
Hey I was trying solve this problem . Where you're asked to segment out "zebra" out of image. Below is the given image.
And output should be like this.
Well I got stuck at "strips" of zebra cause they may get segmented as separate objects.
In image processing, it is important to look at your image and try to understand the difference between your region of interest, i.e. the zebra, and the rest, i.e. background.
In this example, a clear difference is that the background is rather greenish and the zebra black and white. Therefore, the green channel of the image can be used to extract the background. Afterwards the result can be (non-linearly) cleaned up using some dilation and erosion steps.
A simple and non-perfect segmentation technique is (in Matlab):
I = imread('lA196m.jpg');
% plot the original image
figure
subplot(2,2,1)
imshow(I)
% calculate the green channel (relative green value)
greenChannel = double(I(:,:, 2))./mean(I(:,:,:), 3);
binary = greenChannel > 1; % apply a thresshold
subplot(2,2,2)
imshow(binary);
% remove false positives (backgrounds)
se1 = strel('sphere',20);
binary2 = imdilate(imerode(binary,se1), se1);
subplot(2,2,3)
imshow(binary2);
% add false negatives
se2 = strel('sphere',10);
binary3 = imerode(imdilate(binary2,se2), se2);
subplot(2,2,4)
imshow(binary3);
% calculate & plot the boundary on the original image
subplot(2,2,1)
Bs = bwboundaries(~binary3);
B = Bs{1};
hold on
plot(B(:, 2), B(:, 1), 'LineWidth', 2);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on visualization tree map which shows the product categories.There are two values of any range.First value decides size of segments and second value decides the color of segments.Now the conditions is if value is +ve then color range must be vary between green color and if -ve then value vary between red color (for big value color effect will be more dark and for small value color effect will be more light )
How do I done this .
the value ranges between 12 to 8 digits (- or +ve)
Help me please.
You would want start by looking at the colorWithHue:saturation:brightness:alpha: method of UIColor. The hue value will control choice between greens and reds. The saturation and/or brightness value will determine the "darkness", depending on what exactly you mean by "dark".
You can create a simple app with a UISliders for hue/sat/brightness and a UIView to display the selected color to experiment with HSB colors. Here's a gist that implements such a tool.
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 4 years ago.
Improve this question
I am making a top down, rpg-type game - similar to Pokemon, but I am stuck at character movement. Basically, what I want to achieve is a smooth tile based movement system for my player and other people on the map. Has anyone managed to do this effectively? If so, how?
If you are using a grid system, like Pokémon uses, you might be able to achieve this by setting a speed at which they can move between tiles.
For example, if you made it so that they can move one tile a second, you can then use (float)gameTime.ElapsedGameTime.TotalSeconds in your Update function to determine how quickly the game is updating. From this, you should be able to make it so that the character moves ((float)gameTime.ElapsedGameTime.TotalSeconds * TileSize) each update.
This would mean that if they have 4 updates a second (very slow, but for example), they would move 1/4 of the distance across the tile every update, and reach the end point by the end of the movement time period (1 second in this case). In this situation, if you had 32 pixel tiles, they would move 0.25 * 32 every update, or 8 pixels.
Hope this helps.
The 'technical' word for what you want is probably 'interpolation'.
I think the simplest thing you want to do is interpolate the unit position between its starting point (the middle of starting tile) and its ending point (the middle of ending tile) in the time period you want to give it a smooth movement.
Formula goes something like this:
float k = timeSinceStarted / durationOfMovement;
pos.X = startPos.X + (endPos.X - startPos.X) * k;
pos.Y = startPos.Y + (endPos.Y - startPos.Y) * k;
In a game, it's probably better to pre-compute the delta, and add increments instead of storing start position. Something like this (Note: I haven't double checked this computation).
delta = endPos - startPos;
position += delta * (timeSinceLastUpdate / durationOfMovement);