Comments (6)
Interesting, I will give it a try,
thanks for the feedback.
from tinygraphs.
@ajstarks when the I use the same style over the whole loop it definitly makes sense to use canvas.Gstyle()
, Thanks.
In the case of multiple styles in the same loop it is a bit harder as you would have to create a loop for each style.
Should I also try to use Gstyle in this type of scenario?
for ... {
style1 := ....
style2 := ....
if something {
canvas.Line(...., style1)
} else {
canvas.Line(..., style2)
}
}
from tinygraphs.
Nah, it's not worth it in the case you cite. Gstyle is useful for invariants. However, if you can make the decision outside of the loop, you can assign two styles before the loop and then apply them.
style1 := ....
style2 := ...
for ... {
if something {
canvas.Line(...., style1)
} else {
canvas.LIne(...., style2)
}
}
Another useful pattern is to combine Gstyle() for the common style items, and then add variation in the loop as needed.
from tinygraphs.
Cool, thanks
I was able to clean some of the roots where I was creating a fill each time.
See --> 60203d4
And I also manage to use the pattern you described (Gstyle() then add variations).
See --> c6cafeb
from tinygraphs.
in revision c6cafeb you can eliminate the var fill, and then do:
if colorIndex[yL] == 0 {
canvas.Polygon(xs, ys, draw.FillFromRGBA(colorMap[yL]))
}
from tinygraphs.
good spot, I will simplify that 👍
from tinygraphs.
Related Issues (20)
- try it out section should update url HOT 1
- no smooth scrolling from footer links
- add svg images
- run go fmt -s
- run gocyclo
- run golint
- run go vet
- cache routes
- use canvas.TranslateRotate() in hexa16
- Add jpeg format for space invaders
- Add HTTPS support HOT 4
- Hexa Isogrids not filling entire space HOT 5
- online tinygraphs is broken ! HOT 1
- Tinygraph server is down again HOT 1
- tinygraphs on aws lambda
- Do you plant to provide more graphisms ? / color customization
- What are the alternatives of tinygraphs ?
- Everything is broken
- https://www.tinygraphs.com/ Is Down
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinygraphs.