logo
Tags down

shadow

How to move text with the wheel in the canvas


By : Sheldon Cooper
Date : September 16 2020, 07:00 AM
I think the issue was by ths following , , As discussion in comments
code :
body {
		text-align: center;
		padding: 100px 0 0 0;
		color: #fff;
		background: #1d1f20;
}

.wheel {
		width:255px;
	  height:255px;
	margin: 0 auto;
	position: relative;
	-webkit-animation: rotation 4s infinite linear;
}

@-webkit-keyframes rotation {
		from {
				-webkit-transform: rotate(0deg);
		}
		to {
				-webkit-transform: rotate(359deg);
		}
}

.wheel span{
	position: absolute;
}
span.fir {
    top: 45px;
    left: 122px;
}
span.sec {
    top: 75px;
    right: 62px;
    transform: rotate(45deg);
}
span.thi {
    top: 135px;
    right: 51px;
    transform: rotate(101deg);
}
span.frt {
    top: 190px;
    right: 92px;
    transform: rotate(-230deg);
}
span.fiv {
    top: 190px;
    left: 92px;
    transform: rotate(-136deg);
}
span.six {
    top: 135px;
    left: 51px;
    transform: rotate(-111deg);
}
span.svn {
    top: 75px;
    left: 62px;
    transform: rotate(-52deg);
}
<div class="wheel" >
<img src="https://cdn.iconscout.com/icon/premium/png-256-thumb/car-wheel-2-827505.png">
	<span class="fir">hi</span>
	<span class="sec">hi</span>
	<span class="thi">hi</span>
	<span class="frt">hi</span>
	<span class="fiv">hi</span>
	<span class="six">hi</span>
	<span class="svn">hi</span>
</div>


Share : facebook icon twitter icon

jQuery animate to move text on a canvas


By : Shawn Nordmann
Date : March 29 2020, 07:55 AM
this will help All of the examples of using animate I have seen have been using HTML elements. In my game I just have the canvas element and all the text is being drawn on the canvas. I want to be able to create text on the screen and have it scroll from left to right on the canva. , The question is
code :
$({ left: 300 }).animate({ left: 10 }, {duration: 5000, step: function(now, fx) {
    moveMyFrackingCanvas(now);
}});

function moveMyFrackingCanvas(val) {
    var c=document.getElementById("myCanvas");
    c.width = c.width;
    var ctx=c.getContext("2d");
    ctx.font="30px Verdana";
    var gradient=ctx.createLinearGradient(0,0,c.width,0);
    gradient.addColorStop("0","magenta");
    gradient.addColorStop("0.5","blue");
    gradient.addColorStop("1.0","red");
    ctx.fillStyle=gradient;
    ctx.fillText("Holy Crap!", val, 90);
}

Unity Get Canvas UI Text position for gameobjects move destination


By : darkknightm
Date : March 29 2020, 07:55 AM
this will help Canvas elements in the editor are position such that 1 world unity = 1 pixel based on the size and resolution of your camera, thats why it is such a large number. When you actually enter play mode however, all of that stuff just gets mapped onto the screen.
While your UI Text doesn't really have a world position (as far as I understand) because its a Canvas element (assuming you didn't set the canvas to use world positions), you could find out in general where it is by having an invisible plane attached in front of the camera, and doing raycasts to that particular point on the screen then using the result of that raycast as the position to move your Mesh Text to.

HTML5 canvas text orientation circle inside wheel


By : user1859835
Date : March 29 2020, 07:55 AM
this will help I'm not very sure if this is what you are asking. I am calculating the point where the letter should apear and I'm painting the letter without rotating. In the code I've marked the changes I've made.
code :
var wheelNumbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"];
//16 20 18 55 5 25
var wheelABCDEF = ["", "", "", "", "E", "", "", "", "",
  "", "", "", "", "", "", "A", "", "C", "",
  "B", "", "", "", "", "F", "", "", "", "", "",
  "", "", "", "", "", "", "", "", "",
  "", "", "", "", "", "", "", "", "", "",
  "", "", "", "", "", "D", "", "", "", ""
];


var backgroundColours = ["#ffff00", "#ffff00", "#ffff00", "#ffff00", "#005def", "#ffff00", "#ffff00", "#ffff00", "#ffff00", "#66ffff", "#66ffff", "#66ffff", "#66ffff", "#66ffff", "#66ffff", "#005def", "#66ffff", "#005def", "#66ffff", "#005def", "#c0c0c0", "#c0c0c0", "#c0c0c0", "#c0c0c0", "#005def", "#c0c0c0", "#c0c0c0", "#c0c0c0", "#c0c0c0", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#33cc33", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ff99ff", "#ffffbb", "#ffffbb", "#ffffbb", "#ffffbb", "#ffffbb", "#005def", "#ffffbb", "#ffffbb", "#ffffbb", "#ffffbb"];
var startAngle = 4.7;
var arc = Math.PI / (wheelNumbers.length / 2);


var ctx;

function drawWheel() {
  var canvas = document.getElementById("canvas");

  canvas.width = canvas.scrollWidth;
  canvas.height = canvas.scrollHeight;

  if (canvas.getContext) {
    var outsideRadius = 150;
    var insideRadius = 120;
    var textRadius = 160;

    ctx = canvas.getContext("2d");
    //ctx.clearRect(0,0,400,400);

    //ctx.strokeStyle = "black";
    ctx.lineWidth = 0.8;

    ctx.font = 'bold 12px Helvetica, Arial';

    for (var i = 0; i < wheelNumbers.length; i++) {
      var angle = startAngle + i * arc;
      ctx.fillStyle = backgroundColours[i];

      ctx.beginPath();
      ctx.arc(200, 200, outsideRadius, angle, angle + arc, false);
      ctx.arc(200, 200, insideRadius, angle + arc, angle, true);
      ctx.stroke();
      ctx.fill();
      //
      ctx.save();
      //ctx.shadowOffsetX = -1;
      //ctx.shadowOffsetY = -1;
      //ctx.shadowBlur    = 0;
      //ctx.shadowColor   = "rgb(220,220,220)";
      //'#005def'
      ctx.fillStyle = '#444';
      
      /////////////////////////////////////////////////
      // calculating the position for the letter
      var x = 200 + Math.cos(angle + arc / 2) * 100;
      var y = 200 + Math.sin(angle + arc / 2) * 100;
      /////////////////////////////////////////////////
      
      ctx.translate(200 + Math.cos(angle + arc / 2) * textRadius, 200 + Math.sin(angle + arc / 2) * textRadius);
      ctx.rotate(angle + arc / 2 + Math.PI / 2);
      var text = wheelNumbers[i];
      ctx.fillText(text, -ctx.measureText(text).width / 2, 0);
      ctx.restore();// restore goes here
      
      
      text = wheelABCDEF[i];
      ctx.fillStyle = '#005def';

      // paint the letter  without rotating
      ctx.fillText(text, x, y);


      

    }

  }
}



drawWheel();
<canvas id="canvas" width="400" height="400"></canvas>

How to move the text inside the canvas like the text bar animated?


By : Marcos Castro
Date : March 29 2020, 07:55 AM
will help you As I've commented, inside your setInterval function you should add ctx.clearRect(0,0,c.width,c.height). Also you have to redraw everything else. So I've putted your shapes inside functions, and I'm calling those functions inside setInterval too.
code :
var pointX, pointY , w , h ;

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
c.width = 1000;
c.height = 650;
ctx.clearRect(0, 0, ctx.canvas.width,ctx.canvas.height);

function drawShape1(){
  ctx.beginPath();
    ctx.strokeStyle='red';
    ctx.strokeRect(10,0,720,576);
    ctx.closePath();
    ctx.beginPath();
    ctx.fillStyle='grey';
    ctx.fillRect(10,525,720,50);
    ctx.closePath();
}

function drawShape2(){
     pointX = 690;
     pointY = 550;
     w = 30;
    h = 20;
    ctx.beginPath();
    ctx.strokeStyle='red';
    ctx.strokeRect(pointX,pointY,w,h);
    ctx.closePath();
}
    

    var start = 10;
 
setInterval(function(){
 ctx.clearRect(0,0,c.width,c.height)
 drawShape1() 
 start += 4;
 ctx.font = "30px Arial";
    ctx.fillStyle = "red";
     ctx.textAlign = "left";
    ctx.fillText("Hello World",start, 560); 
  drawShape2() 
  }, 40);
<canvas id="myCanvas" width="1000" height="650"  class="col-12 col-s-12" ></canvas>
var pointX, pointY , w , h ;

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
c.width = 1000;
c.height = 650;
ctx.clearRect(0, 0, ctx.canvas.width,ctx.canvas.height);

function drawShape1(){
  ctx.beginPath();
    ctx.strokeStyle='red';
    ctx.strokeRect(10,0,720,576);
    ctx.closePath();
    ctx.beginPath();
    ctx.fillStyle='grey';
    ctx.fillRect(10,525,720,50);
    ctx.closePath();
}

function drawShape2(){
     pointX = 690;
     pointY = 550;
     w = 30;
    h = 20;
    ctx.beginPath();
    ctx.strokeStyle='red';
    ctx.strokeRect(pointX,pointY,w,h);
    ctx.closePath();
}
    

    var start = 10;
 
function frame(){
 requestAnimationFrame(frame)
 ctx.clearRect(0,0,c.width,c.height)
 drawShape1() 
 start += 2;
 ctx.font = "30px Arial";
    ctx.fillStyle = "red";
     ctx.textAlign = "left";
    ctx.fillText("Hello World",start, 560); 
  drawShape2() 
  }

frame()
<canvas id="myCanvas" width="1050" height="1050"  class="col-12 col-s-12" >
                </canvas>

How would one move an object in HTML5 canvas using text input?


By : Arvind
Date : March 29 2020, 07:55 AM
will be helpful for those in need Here's a working example for you. Simply type a number into the text input and press enter. Try it at https://jsfiddle.net/w97zp61u/
Related Posts Related Posts :
  • Send web push notification to all subscribers in one call
  • async script src inside script tag, GDPR complilance google ads
  • Modify Javascript object that API sends
  • Ajax call not triggering
  • How to get everything between two words
  • React Props for Handle Change not a Function
  • How i can iterate over nested section elements?
  • React Native ViewPager with a KeyboardAvoidingView as parent doesn't keep the keyboard up - iOS
  • List field contents not displaying with .val function
  • GET error 400 bad request on second axios api call
  • React & dealing with asynchronous state
  • How to see if an array has a value, and return true if it does. - JavaScript
  • Extract a phone number from a web page then do something with it
  • Unit testing ember-concurrency tasks and yields
  • Not able to read below JSON using Angular 7
  • Load Content for Bootstrap 4 Modal Externally Using JavaScript/ jQuery
  • How to add a material (.mtl) to an object (.obj) using three.js?
  • prevent remount when component is wrapped in parent
  • How to find the values form array of objects
  • How to send multiple data using ajax jquery?
  • Add two columns and display result in third column in HTML Table
  • Adding a class to an object depending on which file the object is being used
  • Manipulating SVG Path Coordinate with Vanilla JavaScript
  • how to fix heroku error while deploying an expressjs app?
  • Fetching past messages into a file
  • Check if click linked in array has a submenu key value. IF true run some code ELSE run other code
  • How to dynamically add vue bootstrap dropwdown list item?
  • How to solve "cannot set property of undefined" on JS?
  • why does focus loose from the html input element when i return input component from custom React Hooks?
  • Fail to set state REACT/JS: Cannot read property 'map' of undefined
  • Typescript, problem with "this" inside arrow functions and rxjs
  • How does website display notifications after its page closed?
  • Choose countries in html/js with translate
  • How to remove this image border?
  • Gatsby: Calling `touchNode` on page node throws 'TypeError: locationAndPageResources.pageResources is undefined'
  • Vue - make output from global function reactive
  • displaying currency symbol before value using data attribute
  • AJAX and head/foot updates best practice
  • How to use onclick function on button. When Button has no ID and Name, it only has class?
  • Passing process.stdout.write directly vs through callback gives different output?
  • jquery prev-next visible selector
  • Error in running scheduled script from suitelet form script in Suitescript 2.0?
  • Use a React prop (string) in GraphQL query template
  • Why is my countdown function not working?
  • Calling a function inside forEach
  • How to publish event from a component and receive it from another component in nativescript
  • How are multiple line inputs handled?
  • Is there a better way to do complex animations with start and end animations that are randomized?
  • how to replace src domian tld
  • Unable to use JsRuntime.InvokeAsync from OnAfterRenderAsync in Blazor Server-Side App
  • ReferenceError: document is not defined at Object.<anonymous>
  • How do I iterate through an object using .map?
  • Javascript detect if native emoji is supported
  • Having problem in putting headings in react
  • Nesting multiple for using in
  • minimal introduction of promise async await?
  • NetSuite : TypeError record.createCurrentLineItemSubrecord is not a function?
  • Django Contact Form With Google Recaptcha v3
  • Stop countdown time
  • How do I start a function from within a *ngIf directive?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk