Code Monkey home page Code Monkey logo

livepreview's Introduction

LivePreview

Two methods (in seperate branches) for providing Live Previews of your watchface/watchapp to the user when allowing them to use custom color pickers.

PNG Method by @NiVZ

SVG Method Method by @Gregoiresage

Brief Instructions - These will be updated later

To use the PNG version you will need:

  • Your favourite image editing program
  • Program or website to convert PNG to Base 64
  • Cloudpebble or Local SDK
  1. First take a screenshot of your watchface/watchapp and save as a .png
  2. Load it into your favourite image editing software
  3. You need to give each element that can be colored seperately a unique color (eg background RED, hour hand GREEN, minute hand BLUE)
  4. If multiple elements need to be set using the same color picker (eg button labels for Light, Prev, Next then make these the same color)
  5. Save the image
  6. Convert the image to Base 64
  7. Open your project in Cloudpebble or Local SDK
  8. Create your Clay configuration as normal, but make sure to add the following section above your color pickers: { "type": "text", "id": "canvas", "defaultValue": '' }
  9. Edit the custom-clay.js
  10. Replace the imgB64 string with the string for your Base 64 encoded image
  11. Edit the 'originalColor' object giving it the KEY name for your clay config color pickers, and the hex code of the unique color you used to identify that element in the Base 64 encoded image.

That's it!

How it works:

The PNG method works by always loading your unique colored image so it has a known starting point It then loops through every individual pixel of the unique colored image and compares it to the colors you specified in the 'originalColor' object. When it finds a match it now has the name of the KEY It then gets the currently selected color from the picker with the matching KEY name and replaces the pixel color Once all pixels have been done the whole image is redrawn back to the canvas This function is triggered onload and whenever a color picker value is changed

livepreview's People

Contributors

nivz78 avatar gregoiresage avatar

Stargazers

Morris avatar Ish Ot Jr. avatar Thomas Hunsaker avatar  avatar

Watchers

James Cloos avatar Ish Ot Jr. avatar  avatar  avatar

Forkers

gregoiresage

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.