HTML5 advice on drawings and images (canvas, SVG) - html

I'm looking into creating a website that allows people to create their own designs for a certain product. This product can have straight lines, curves, squares, and various shapes. I would not only like these people to be able to free hand draw their own artwork, but also be able to drag and drop (or just click in an area) certain stock images onto the template. I started this project using HTML/Canvas, and have implemented the drawing of freehand/shapes/lines, but I've read a few places that say I should be using SVG for the images.
Reading that I should use SVG for images made me think that since I'm a novice on HTML and website design in general, that I should possibly be doing this differently. So I was wondering how some people would implement this. For a good concept, think of a web site that people can design their own T-Shirts. You just draw on a square canvas, circles/squares/lines/free hand, but can also stick stock photos on there. Thanks, and I'm not looking for code, just to know if I should be using a mix of HTML/SVG/Canvas, or something completely different that I don't know about.
to summarize....
svg, or canvas.......or both, or something else completely.

Okay this is how i imagine you want it to work:
Your customers select a tshirt size and style.
An embedded application within your website allows the users to draw
a nice design they want or import an image
A price is calculated based on the size of the tshirt and the size
of the print
Upon succesful payment, you receive on your backend an image of the
print, the order details and you feed that image into your T-shirt
printing thingy, you print it and you post it.
If this is right you should consider this: http://svg-edit.googlecode.com/svn/branches/2.6/editor/svg-editor.html
You will probably want to remove some unnecessary tools from it and fire it up with different configurations based on what kind of tshirt the customer selected. One example is the t-shirt size. If a customer selects a small t-shirt you fire up a smaller drawing size. The list goes on.
You need to have some good JS skills however to be able to play around with SVG-edit because it is massive but from what i feel it fits perfectly to your purposes.
If you want to see the differences between SVG and Canvas read this: http://dev.opera.com/articles/view/svg-or-canvas-choosing-between-the-two/. Its pretty straightforward.
Now why did i suggest using SVG-edit? I don't know if there is any other application implemented using canvas that has so many tools and works so nice as SVG-edit.
It has everything you need, including a '''SAVE as PNG'' function which will serve your purposes in case your t-shirt printer doesn't print SVG images.

Related

best method for interactive site map

I've been asked to make an interactive site map for a local development which has a few houses on it, so users can click on the relevant house within an aerial site layout, and see it's details listed, and whether or not it's sold.
Staff need to be able to mark houses as 'sold'.
It's been a while since I've done anything like this - in the past I would have used flash and had the sold status updated via actionscript and php, but things have moved on. What are some of the most popular methods now?
I've included an example below which is a lot larger scale than what I'm looking to do, but the same principle. I can't work out how they did it though, and I'd really like it to be vector so it can be zoomed into without losing quality, plus have the option to animate things like the popup bubbles etc if the tech allows.
Also, I'd probably be looking to include this in a Kirby CMS site, and hopefully have the updating done through that, but it's fairly flexible.
Thoughts appreciated!
https://www.redrow.co.uk/developments/the-sycamores-162433/interactive-site-map-4803v1

How to integrate and Program Avatar customization in HTML(5)?

I am making a Game in HTML5. In one part of it, I want the users to be able to customize the avatar they get by default.
For sample, let me share a screenshot from Zombie Lane on Facebook (now this game may not be in HTML5 but that's not the point):
My question is as to how do I include the images in the HTML5 page and in which format?
Whenever a clothing is different shirt is selected, the change is applied immediately. Is it a whole new photo that we see, or is the photo changed somehow by programming? How is it done?
NOTE: I do not want to get into 2D/3D rendering or any complicated algorithms, what's the simplest way?

Is it possible to accomplish the equivalent of a Flash-driven webcomic (zoom, drag, fade in, synced audio etc) using HTML5 techniques?

Bit of background
I've been producing a Flash-driven webcomic for three years now, incorporating some basic animation, a synced soundtrack and zoom-drag page viewing. The recent Flash-bashing, my desire to reach iHandhelds and my preference for open versus proprietary means that I want to make the move to HTML5 techniques this year. In the long-term, I think the writing's on the wall for Adobe's product, and I'm not entirely convinced that's a bad thing.
I'm relatively comfortably with both CSS and HTML, having worked a little in web design before. However, JavaScript is a foreign country to me, and I simply wanted to get some advice as to
whether what I want to achieve can be accomplished consistently across all browsers and
what the best techniques/approaches to the problem would be.
Any advice, even general principles, are very welcome. I've already sought out several HTML5 tutorials and introductions, which lead me to believe that the canvas element will be foundational to my plan; however while all the individual problems I face have been answered by many blogposts and guides, combining the various solutions into a single entity is something I'm not currently able to figure out, as I'm not certain of the limitations of the new HTML5 tags, or of best practice.
If I'm successful in achieving what I'm after, I'm going to post the full code online with an explanation of all the elements. Webcomics might not be a huge domain, but having a resource that did this would have made my life a lot easier - hopefully it'll help someone else in a similar position.
What I'm after
Here's a diagram giving the basics of the design requirements. I'll explain the elements, and the desired extras, below.
(Perhaps the simplest way to demonstrate what I'm after would be for interested folks head over to my website and see how my comic currently works. This isn't a plug - it would simply give the quickest insight.)
At core, I'm after a viewer that will:
display text (SVG image) in a canvas element above an raster image the page's panel art
both images should be zoom-and-draggable in sync but should ideally fade in separately, with the raster image coming first, followed by the SVG image
I'm guessing that the best way to accomplish this would be to layer two canvas elements one above the other using z-index, with the SVG file in the uppermost element. These could then be nested, as in the diagram, within a div element that would carry the zoom-drag function. Is this a reasonable approach, or are there more efficient options?
The next and previous buttons are self-explanatory. Would it best to have each page (bearing in mind some will involve animation and music) on a separate page, or to have all pages within a chapter on a single page, with the buttons making them visible progressively? I imagine this would have a great impact on loading speeds.
Finally, I'd like to have the viewer capable of displaying fullscreen if the reader desires. I imagine this could be accomplished by using Javascript to make the canvas elements and their surrounding div switch between different CSS giving a px-defined size and 100% height and width. Is this a good approach? Is it possible to apply the size change to the div element only and have the canvas elements automatically follow suit, possibly by defining their size via % in CSS?
Desired extras
At various points in the comic I make use of basic animation techniques - simple movements of layered raster images across the viewing pane. This would be simple to accomplish, I imagine, using Javascript; am I correct in thinking that applying overflow:hidden to the wrapping div will prevent images larger than the viewing area from spilling outside the viewer area?
I also want to synchronise audio with some of these animations. I understand that synchronising canvas events with the audio would be the best way to do this on, permitting both to begin activity only upon page loading or next button click.
That's about everything. As said, any advice at whatever level would be greatly appreciated, even if it's 'yes' or 'no' to the various questions I've asked. At root, it would also be good to know if HTML5 is the best option for what I'm after or whether (with gritted teeth) I should stick to Flash for now and go after handhelds using Adobe AIR.

Should I use a sprite-like technique for thumbnails on my website?

On a website I'm creating, I have about 100 various thumbnails (64x64) that get displayed at different times. On some pages, only 5-15 thumbnails may be displayed. On others, all 100 are loaded.
I'm considering using a technique like CSS sprites to display the images. That is, rather than have image tags for each thumb, do something like:
<span class=thumb1"></span>
And then use CSS to take a slice of one single image with all the thumbs stitched together. That is, one image with all 100 thumbs (in this scenario, a 640x640 image).
My questions:
Is this a good idea?
If yes,
should I do it on all pages the
images occur, or only on the pages
with all the images?
Is there
another technique other than sprites
that may be better than simply
including the images with img tags?
If you think that an ordinary user would visit at least two different pages with these thumbnails than my opinion is that using sprites would really be a good idea!
I would in fact make a single big image with all the thumbnails and then use it in all the pages!
Why?
Fewer http requests (from 100 to 1)! And this is one of the most important thing about web site optimizations (read here from Yahoo Performance Team speed optimization rules )
This way users will download the whole image only the first time and then they will get a super quick loading of that images in all the following pages
The most famous websites on the internet already do that! See sprites used in Yahoo, Amazon or Youtube pages.
You can add other UI or layout images to your sprite
Optimize the resulting PNG:
After you have generated your sprite, if a PNG, you can optimize the PNG even more using this tool: http://www.sitepoint.com/blogs/2009/09/18/squishing-the-last-drops-from-your-pngs/
When not to use sprites:
When part of the images in the sprite change frequently
In this specific case: when the majority of users would need less than the (about) 10% of the images
I'm not quite sure what you mean with "sprites", but this is what I think you mean: instead of 100 images seperately, you create 1 image, with a 10x10 raster. Each coordinate (x,y) contains one of the images you like to show.
Now, if you display an image, you use CSS to set background-location: i.e. x * -64px and y * -64px, perhaps using JavaScript to calculate the x and y for each image-span, or Server-Side scripting to print out a dynamic CSS.
Yes, this is a good idea: it reduces load time, since one only has to download one big image, instead of hundreds of smaller ones.
It depends. If you have caching-abilities for a page, then you can "stitch" all thumbnails into one image file. If you have a very dynamic webpage, then it's quite harsh to build this stitched image every time the thumbnales are updated.
Not sure, if this is what you ment with "sprites", then no, if you ment something else with "sprites", then yes: this answer is an example of one.
It is a good idea if
Speed matters
You don't care about accessibility (screen readers reading the ALT text of an image, etc, all that is gone when you use sprites)
You don't care that your thumbnails are not going to be printed by default in any browser
You can do it without it becoming a maintenance nightmare (which image was on position 461 again?)
As to your second question, it is probably advisable to put all sprites into one or very few container images to minimize loading times.

Image manipulation in ActionScript 3.0 : realistically editing faces

I am a flash developer who has worked mostly on small ActionScript projects, in particular websites, but I am dipping my toes into image manipulation with AS3. I have a project I'm working on to develop an application which would allow a user to upload their own picture into a swf, and then, using a slider, they can alter the image to make themselves look thinner or fatter. The condition is that it should require minimal user input - so ideally the most I could expect from the user would be a couple of control points identifying certain areas of the face in response to prompts e.g. 'click on the centre of the chin' and when the user clicks, the position would be stored, but this would need to be used sparingly, if at all.
So far, I have been able to use the FileReference class to handle the upload, and I am experimenting with using the DisplacementMap filter to edit certain parts of the uploaded image, but I am having serious trouble implementing this in a manner that would allow realistic deformation of the facial features in the image uploaded.
Is there anything that exists that might run along the same lines and that provides an explanation/source code I could look at to get a better idea of how to go around doing this? Or if there are any other ideas on how to manipulate and distort the image that doesn't use the DisplacementMap Filter?
Any feedback and help is greatly appreciated. Thank you for your time.
see http://sakri.net/technology/flash/flex/convolution_filter/ConvolutionFilterExplorer.html
(source code available)