Skip to content

Commit

Permalink
logo
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed Aug 27, 2019
1 parent f6e5dfc commit 1a81e07
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 27 deletions.
1 change: 1 addition & 0 deletions .Rprofile
Expand Up @@ -8,3 +8,4 @@ shim_system_file <- function(package) {

shim_system_file("htmlwidgets")
shim_system_file("htmltools")
devtools::load_all()
7 changes: 4 additions & 3 deletions R/animation.R
Expand Up @@ -68,10 +68,11 @@ animation_rotate = function(rdog = NULL,

#' @export
animation_ease_in = function(rdog,
id,
addTo,
id = NULL,
addTo = NULL,
frames = Inf,
framesPerCycle = 150,
pause = 0,
radiansPerCycle = tau,
rotateAxis = 'y',
power = 2){
Expand All @@ -88,7 +89,7 @@ animation_ease_in = function(rdog,

animationScript = glue::glue(
'
Rdog_variables.built_in.animation_ease_in("<id>","<addTo>","<illoId>",<frames>,<framesPerCycle>,<radiansPerCycle>,"<rotateAxis>",<power>);
Rdog_variables.built_in.animation_ease_in("<id>","<addTo>","<illoId>",<frames>,<framesPerCycle>,<pause>,<radiansPerCycle>,"<rotateAxis>",<power>);
',.open = '<',.close = '>')

if('htmlwidget' %in% class(rdog)){
Expand Down
14 changes: 7 additions & 7 deletions R/shapes.R
Expand Up @@ -344,7 +344,7 @@ shape_shape = function(
assertthat::assert_that(is.list(path))

seq_along(path) %>% sapply(function(i){
if(is.null(names(path)[i]) | names(path)[i] == ''){
if(is.null(names(path)[i]) || names(path)[i] == ''){
assertthat::assert_that(!is.list(path[[i]]),msg = 'Nested elements in path must have names')
return(process_coord_vector(path[[i]]))
} else{
Expand Down Expand Up @@ -626,12 +626,12 @@ shape_box= function(rdog = NULL,
width = 1,
height = 1,
depth = 1,
frontFace = '#333',
rearFace = '#333',
leftFace = '#333',
rightFace = '#333',
topFace = '#333',
bottomFace = '#333',
frontFace = color,
rearFace = color,
leftFace = color,
rightFace = color,
topFace = color,
bottomFace = color,
color = '#333',
stroke = 1,
fill = TRUE,
Expand Down
3 changes: 2 additions & 1 deletion README.Rmd
@@ -1,5 +1,4 @@
---
title: "rdog"
output: github_document
editor_options:
chunk_output_type: console
Expand All @@ -10,6 +9,8 @@ knitr::opts_chunk$set(echo = TRUE)
devtools::load_all()
```

# Rdog <img src="logo.gif" align="right" height="150"/>

This is a port of the [zdog](https://zzz.dog/) pseudo 3D engine for R.
Currently a work in progres.

Expand Down
4 changes: 2 additions & 2 deletions README.md
@@ -1,5 +1,5 @@
rdog
================

# Rdog <img src="logo.gif" align="right" height="150"/>

This is a port of the [zdog](https://zzz.dog/) pseudo 3D engine for R.
Currently a work in progres.
Expand Down
Binary file modified README_files/figure-gfm/unnamed-chunk-1-1.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 31 additions & 14 deletions inst/htmlwidgets/lib/zdog-1.0.2/rdog_variables.js
Expand Up @@ -118,14 +118,16 @@ Rdog_variables.built_in.animation_rotate = function(id, add_to, illo_id, frames,



Rdog_variables.built_in.animation_ease_in = function(id, add_to, illo_id, frames, framesPerCycle, radiansPerCycle, rotateAxis, power){
Rdog_variables.built_in.animation_ease_in = function(id, add_to, illo_id, frames, framesPerCycle, pause, radiansPerCycle, rotateAxis, power){
Rdog_variables.utils.set_up_vars(id, add_to, illo_id);

// keep the needed variables in a globally accessible object instead of using
// let to prevent values from getting lost if the original function is terminated.
if (Rdog_variables.animation_variables[id] === undefined){
Rdog_variables.animation_variables[id] = {};
Rdog_variables.animation_variables[id].ticker = 1;
Rdog_variables.animation_variables[id].pausing = false;
Rdog_variables.animation_variables[id].pauseTicker = pause;
}

//ticker = 0
Expand All @@ -137,23 +139,38 @@ Rdog_variables.built_in.animation_ease_in = function(id, add_to, illo_id, frames
frames -= 1;

let ticker = Rdog_variables.animation_variables[id].ticker;

let progress = ticker/framesPerCycle;
let previousProgress = (ticker-1)/framesPerCycle;
let rotation = Zdog.easeInOut( progress % 1, power );
let previousRotation = Zdog.easeInOut( (ticker-1)/framesPerCycle % 1, power );
let delta = 0;

if(rotation>previousRotation){
delta = rotation - previousRotation;
let pausing = Rdog_variables.animation_variables[id].pausing;

if(!pausing){
let progress = ticker/framesPerCycle;
let previousProgress = (ticker-1)/framesPerCycle;
let rotation = Zdog.easeInOut( progress % 1, power );
let previousRotation = Zdog.easeInOut( (ticker-1)/framesPerCycle % 1, power );
let delta = 0;

if(rotation>previousRotation){
delta = rotation - previousRotation;
} else{
if(pause>0){
Rdog_variables.animation_variables[id].pausing = true;
}
delta = 1+rotation-previousRotation;
}

window[add_to].rotate[rotateAxis] += delta * radiansPerCycle;

ticker++;
Rdog_variables.animation_variables[id].ticker = ticker;
} else{
delta = 1+rotation-previousRotation;
Rdog_variables.animation_variables[id].pauseTicker -=1;
if(Rdog_variables.animation_variables[id].pauseTicker === 0){
Rdog_variables.animation_variables[id].pausing = false;
Rdog_variables.animation_variables[id].pauseTicker = pause;
}

}

window[add_to].rotate[rotateAxis] += delta * radiansPerCycle;

ticker++;
Rdog_variables.animation_variables[id].ticker = ticker;

// record any changes to the original object and illustration
Rdog_variables.animRotating_objects[add_to] = window[add_to];
Expand Down
Binary file added logo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1a81e07

Please sign in to comment.