forked from trpo-moais-2016/fg01-snowflake
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simple koch fractal app #2
Open
DerArvend
wants to merge
11
commits into
trpomoais2018:master
Choose a base branch
from
DerArvend:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3904b15
update gitignore for react
DerArvend 00db8be
add package.json
DerArvend 5ed9796
move index.html and remove example code
DerArvend cf87907
add favicon
DerArvend a8c571e
index files and package.json
DerArvend d02f156
koch fractal
DerArvend f9e1b10
refactor
DerArvend 0a9c6eb
preparation for deploy
DerArvend 90d3f15
add image
DerArvend 442bbad
update readme
DerArvend f811d69
fix readme
DerArvend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor
- Loading branch information
commit f9e1b1063c8417e7fa537c102e94ca678b7e9f9a
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
// import React from 'react'; | ||
// import RecursionDepthSlider from "./RecursionDepthSlider"; | ||
// | ||
// class FractalApp extends React.Component { | ||
// constructor(props) { | ||
// super(props); | ||
// this.state = { | ||
// currentDepth: 1 | ||
// } | ||
// } | ||
// | ||
// render() { | ||
// return ( | ||
// <div> | ||
// <h1>Снежинка Коха</h1> | ||
// <RecursionDepthSlider/> | ||
// </div> | ||
// ); | ||
// } | ||
// } | ||
import React from 'react'; | ||
import RecursionDepthSlider from './RecursionDepthSlider'; | ||
import {drawKochFractal} from '../kochSnowflake'; | ||
import DrawingBox from './DrawingBox'; | ||
|
||
class FractalApp extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
currentDepth: 1 | ||
}; | ||
} | ||
|
||
handleSlider = (event, value) => { | ||
let canvas = document.getElementById('fractal-canvas'); | ||
drawKochFractal(canvas, value); | ||
this.setState({currentDepth: value}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<h1>Снежинка Коха</h1> | ||
<RecursionDepthSlider onChange={this.handleSlider} value={this.state.currentDepth}/> | ||
<p>Глубина рекурсии: {this.state.currentDepth}</p> | ||
<DrawingBox size={500}/> | ||
</div>); | ||
} | ||
|
||
componentDidMount () { | ||
let canvas = document.getElementById('fractal-canvas'); | ||
drawKochFractal(canvas, 1); | ||
} | ||
} | ||
|
||
export default FractalApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,22 @@ | ||
import React from "react"; | ||
import {MuiThemeProvider, Slider} from "material-ui"; | ||
import {drawKochFractal} from "../kochSnowflake"; | ||
import React from 'react'; | ||
import {MuiThemeProvider, Slider} from 'material-ui'; | ||
|
||
class RecursionDepthSlider extends React.Component { | ||
state = {slider: 1}; | ||
handleSlider = (event, value) => { | ||
let canv = document.getElementById('fractal-canvas'); | ||
drawKochFractal(canv, value); | ||
this.setState({slider: value}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<MuiThemeProvider> | ||
<Slider | ||
min={1} | ||
max={7} | ||
step={1} | ||
value={this.state.slider} | ||
onChange={this.handleSlider} | ||
style={{ | ||
marginRight: '30%', | ||
marginLeft: '30%', | ||
marginBottom: '-40px' | ||
}}/> | ||
<p>Глубина рекурсии: {this.state.slider}</p> | ||
|
||
</MuiThemeProvider>); | ||
} | ||
function FractalDepthSlider(props) { | ||
return ( | ||
<MuiThemeProvider> | ||
<Slider | ||
min={1} | ||
max={8} | ||
step={1} | ||
value={props.value} | ||
onChange={props.onChange} | ||
style={{ | ||
marginRight: '30%', | ||
marginLeft: '30%', | ||
marginBottom: '-40px' | ||
}}/> | ||
</MuiThemeProvider>); | ||
} | ||
|
||
export default RecursionDepthSlider | ||
|
||
export default FractalDepthSlider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import React from 'react' | ||
import {render} from 'react-dom' | ||
import RecursionDepthSlider from './components/RecursionDepthSlider' | ||
import DrawingBox from "./components/DrawingBox"; | ||
import FractalApp from './components/FractalApp'; | ||
|
||
render(<RecursionDepthSlider/>, document.getElementById('slider')); | ||
render(<DrawingBox size={500}/>, document.getElementById('canvas')); | ||
|
||
render(<FractalApp/>, document.getElementById('root')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не стоит делать замыкание для одного вызова: кода больше становится, а смысл тот же.