We are about to switch to a new forum software. Until then we have removed the registration on this forum.
how can i convert this java code to processing ive tried a few times but really dont know enough about java or processing thanks in advance for any advice.
<script type="text/javascript">
$(document).ready(function() {
function ReturnConversion(Value) {
//if(Value.Sym
}
var MetricPrefixes = {
"Symbol": {
'tera' : 'T',
'giga' : 'G',
'mega' : 'M',
'kilo' : 'k',
'mili' : 'm',
'micro' : 'μ',
'nano' : 'n',
'pico' : 'p'
},
"Conversion": {
'tera' : 12,
'giga' : 9,
'mega' : 6,
'kilo' : 3,
'mili' : -3,
'micro' : -6,
'nano' : -9,
'pico' : -12
}}
var RegExArray = [];
var ConversionArray = [];
$.each(MetricPrefixes.Symbol,function(K,V) {
RegExArray.push(V);
ConversionArray[V] = MetricPrefixes.Conversion[K];
});
var RegEx = new RegExp('['+RegExArray.join(',')+']');
$('input[name=Ohms]').keyup(function() {
var Symbol = $(this).val().match(RegEx);
var Value = $(this).val().replace(RegEx,'');
if(Symbol) {
var Counter = 0;
while(Counter != ConversionArray[Symbol[0]]) {
if(ConversionArray[Symbol[0]] > 0) {
Value = Value * 10;
Counter++;
}
else {
Value = Value / 10;
Counter--;
var DecimalPlace = ConversionArray[Symbol[0]] - (ConversionArray[Symbol[0]] * 2);
}
}
}
$('b').text(Value.toFixed(DecimalPlace ? DecimalPlace : 0)+' Ohms');
});
});
</script>
Ohms: <input name="Ohms"/><br/>
<b style="font-size:20px;color:green;"></b>
Answers
Please edit your post, select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
Also, please note this is javascript, not java. Check the p5js.org website. People will look up your code after it gets formatted properly.
Kf
thank you how is it now
https://github.com/processing/p5.js/wiki/Processing-transition
Kf
OK thanks again I'll try that
@deeceb --
Notice that the transition page:
...is about turning a desktop-based Processing(Java) into web based p5.js(JavaScript).
If you are trying to do the opposite -- turn a web-based non-p5 JavaScript into a desktop-based Processing(Java) sketch -- then read the directions backwards.
If you are trying to turn a generic web-based JavaScript into a p5.js Processing JavaScript, then you need slight different directions.